0

Am having a issue with ajax form for some reason it dont always work post the correct data am having to click the image 3 or 4 times before it will load the portrait and gallery numbers.

can anyone help me out ?

    **       Form.php**
            <script>
            $(document).ready(function() {
                $('.ajaxform').click(function() 
                {
                   var avatar = $(this).data("portrait");
                   var avatardir = $(this).data("gallery");

                   $.post('update.php', {avatar : avatar, avatardir : avatardir}, function(data, status) 
                   {
                     $("#info").html(data);
                     alert("Data: " + data + "\nStatus: " + status);
                   }); 
                });
            });
            </script>

            <div id="info">
              <input name="updateMyPortrait" type="hidden" id="updateMyPortrait" value="1" />
              <input name="avatardir" type="hidden" id="avatardir" value="<?php echo $_POST['avatardir']; ?>" />
              <input name="avatar" type="hidden" id="avatar" value="<?php echo $_POST['avatar']; ?>" />
            </div>

 **       input image for clicking on:**
           <td><div><input class=\"ajaxform\" data-portrait=\"#{$str3}\" data-gallery=\"#{$avatarimg}\" type=\"image\" src=\"{$files[$pos]}\" width=\"88\" height=\"88\" border=\"1\"></div></td>

  **        update.php:**
            <input name="avatardir" type="hidden" id="avatardir" value="<?php echo $_POST['avatardir']; ?>" />
            <input name="avatar" type="hidden" id="avatar" value="<?php echo $_POST['avatar']; ?>" />

Thanks.

Edited by Simon180

3
Contributors
7
Replies
35
Views
2 Years
Discussion Span
Last Post by Simon180
0

How big is the image file? If it is quite big (even 1 MB), it could take sometimes to load. Ajax is supposed to be for small data transaction so that the client doesn't need to reload the whole page...

Edited by Taywin

0

You could show a loading animation (simple animated gif) on load and hide on completion. In the same way you could set a visual 'disabled' e.g. greyed-out overlay) on the upload trigger.

0

its not loading image only getting the image location basicly gallery ID and Picture ID but it dont seam to be working correctly not always adding the selected ids.

0

WHy is all that html got escape chars all over the place? Are you spitting that out in PHP?!

0

yes all within side of php script, that is aecho "<td><div><input class=\"ajaxform\" data-portrait=\"#{$str3}\" data-gallery=\"#{$avatarimg}\" type=\"image\" src=\"{$files[$pos]}\" width=\"88\" height=\"88\" border=\"1\"></div></td>";

thats reason

Edited by Simon180

0

Oh dear. That.s why it didn.t make any sense. So what is the ajax supposed to do? Just replace numbers in input controls?

0

basicly when you click on a image data-portrait=\"#{$str3}\" AND data-gallery=\"#{$avatarimg}\" will get the image id(portrait) and folder id(gallery) and then post them so I can submit then to database

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.