Saturday, March 24, 2012

AJAX and the Querystring

Having a slight problem with Atlas/Ajax. I have an item page which displays items based on the item id being passed by querystring into the page. The querystring parm is useful for bookmarking the exact product to be displayed on the page and returning to it later. If people click on a "go to next item in item category" button on this page, they get the next item in the category displayed and the URL querystring item parm changes to that item number. I accomplish this with a Response.Redirect to the same page with the new querystring parm value, but I can't seem to do this with an Ajax setup because the redirect loads the page over again.

How do I keep the benefits of Ajax by having a client side refresh without reloading the page and alter the querystring to the new product number?

what u store in the query string could also be stored in the session object & the session object could be passed as a parameter to the database.


That's a good suggestion; but the issue would be the user coming back to the page at a later point, having changed the item id on the querystring via the show next item in category button. They may wander off; close their browser; destroying the session info and then want to return to their "bookmarked" page. Even if I kept the data in the DB for retrieval and could identify that customer coming in again, how would I know which product they were after? What if they bookmarked two different products originally. I wouldn't have the querystring information under AJAX to know that. I don't think I would want to show them "last product viewed" when they come back in.


write a small procedure to evaluate the query string when the user comes back.if there is a query string, pass that to the session & databind.so in any case, whether there is a session variable or not you would be able to databind.

hello.

well, i think that's not he problem he wants to solve. what he needs to do is to change the query string so that it identifies the current product but he doesn't want to perform a navigation when changing the query string.

hum...i really don't know if you'll be able to do that...try to look at the location object, though i really think this is only ie specific


Luis,

I think you described exactly what I want to do. I can do it server side with no issue using a redirect, but client side with AJAX is a problem, even though AJAX does a great job with client side refreshes on the page!


hello.

well, the problem is that what you're trying to do is not an ajax related thing. i mean, for the browser, the query string really isn't something that you can program against. it's just an url, so i think that changing it for adding or modifying a query string parameter will force the browser to navigate to a new url. if this is not a problem to you, then simply changing thw window.location property will do what you want from the client side. however, you should note that this is the same as loading a new page in the browser...

No comments:

Post a Comment