1 Replies - 308 Views - Last Post: 26 October 2013 - 12:53 PM

#1 CONNERtheCODER  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 27-June 13

table positioning with AJAX to PHP post

Posted 26 October 2013 - 11:10 AM

I have a jQuery script that sends POST data via AJAX to a php file that then creates a table. I have used firebug to check the console and everything gets created properly. On the success: I reload the window and the table isn't displayed.

I know the table html was created properly from the php file because I commented out the reload so I could see exactly what it created) I have lots of things displayed on my page and would like the table in a particular spot. How can I get the table to actually display where I want it to?

<script>
$(document).ready(function () {
    $("#stayinfobutton").click(function () {
        var id = $('#id').val();
        var dataString = {
            id: id
        };
        console.log(dataString);
        $.ajax({
            type: "POST",
            url: "classes/table_auto_guests.php",
            data: dataString,
            cache: false,
            /*success: function(html)
                    {
                        window.location.reload(true);
                    }*/
        });
    });
});
</script>


Is This A Good Question/Topic? 0
  • +

Replies To: table positioning with AJAX to PHP post

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3719
  • View blog
  • Posts: 5,994
  • Joined: 08-June 10

Re: table positioning with AJAX to PHP post

Posted 26 October 2013 - 12:53 PM

I don't get the logic here. You send an AJAX request to PHP to get some data from the server, and then as soon as that AJAX request is done you reload the page? How is the data you just got from PHP supposed to carry over from the current page to the newly reloaded page? As soon as you reload the page, whatever PHP sent through that AJAX request is gone.

AJAX is used to fetch data from the server into the current page. If you reload the page, whatever you've done to the page through Javascript is cleared out and the page is restored in it's original state. - That is, unless you somehow have the server persist those changes. (Like, if you update the database, and the reloaded page is rebuild on that.)
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1