tags:

views:

47

answers:

2

Hi!

In index page I manage categories by just putting in url /?cat=mycat attribute. Now, when user clicks a link which start jQuery update. First inserting data in SQL and if success then $("#indexPage").load('updateIndexPage.php') where contains query of index elements from database.

Now, I can't get that to fetch urls attributes (in this case this ?cat=mycats). I have in that updatefile $cat = $_GET['cat']; but it doesn't work??

So what is happening is that when user is some of my cats, and click link after that query is not showing that category stuff where user was.. :)

well that's messy.. :)

+2  A: 

Your call to $.load() isn't actually passing any GET variables to the server. Review the documentation for $.load() again: http://docs.jquery.com/Ajax/load

$.load( url, [data], [callback] )

Note the second parameter is where you would pass in your values. Note also that if you pass these variables using $.load(), they will not show up as GET on the server, but instead POST, as indicated by the documentation:

...will POST the additional parameters to the server and a callback that is executed when the server is finished responding.

$("#feeds").load("feeds.php", {limit: 25}, function(){
   alert("The last 25 entries in the feed have been loaded");
});

To account for this difference, simply change your PHP code to one of the following:

$cat = $_POST["cat"]; // looks for a 'cat' variable in POST
$cat = $_REQUEST["cat"]; // looks for a 'cat' variable in POST or GET
Jonathan Sampson
This was very useful too Jonathan! Thank you..
Marko
+1  A: 

Try passing the window get variables to the Ajax URL:

$("#indexPage").load('updateIndexPage.php' + window.location.search);
David
Thank you David! :)
Marko