AJAX and PHP question

Associate
Joined
4 Mar 2007
Posts
315
Location
United Kingdom
I am experimenting with AJAX and have a table set up with a drop down.
The table is filled from a database handled by the php upon the state of a GET.
I wish to change the GET in the url upon changing the selection from a drop down. How would I go about sending a request to the server to change the GET in the url to update the table without completely refreshing the page?

Regards,
 
Pretty sure that's not possible as the URL is separate from any on-page calls etc.

Why do you need to? There's probably an easier alternative.
 
Well it was more an idea of seeing how I could update the page table content upon changing the drop down. Either through PHP or AJAX but I thought AJAX would be the best choice.
 
No clue about PHP, but this is toughly translated from what I'd do in .Net MVC with jQuery:

1. Make a view that only contains the table (say, table.php).

2. Include it inside a <div id='myTable'> on the parent view (say, main.php).

3. Have the browser load with $('#myTable').load('table.php?...'); to reload the table client side.
 
Code:
$('#mydropdown').bind('change', function(e) {
   var val = $(this).val();
   $.ajax('myselection.php', {'item' : val}, function(data) {
      var mytable = $('#mytable');
      mytable.empty();
      for (var counter = 0; counter < data.length; counter ++) {
         $('<td>'+data[counter]+'</td>').appendTo($('<tr />').appendTo(mytable));
      }
   });
});


Hows that?

EDIT : Something like that anyway
 
Back
Top Bottom