AJAX with Callback Url and Url Rewriters
Dflying | 10 March, 2006 21:25The second parameter of the XmlHttpRequest.open method is the Url of the callback page:
xmlRequest.open("GET", url, true);
So far so good, things seem pretty-much straightforward. However, in a typical ASP.NET setting, an Url rewriter stands between the XmlHttpRequest and the actual page requested, making the Urls friendly to the end-user and search engines. However, this transition may be hostile for AJAX and the rewritten Url may not be what you expect.
There are two ways to pass the callback Url to the javascript callback routine - from the server or hardcode/reflect it from the client.
Server: If you are calling back to the same page, the best way to get the callback Url is using the Page.Request.CurrentExecutionFilePath property - this will take of the Url rewriting as well. Just pass it to your client-side callback function and use it for XmlHttpRequest Url.
Client: If you are calling back to the same page, the best approach is to reflect the current Url in the browser using window.location.href and use this Url to callback to the server.
Posted in
JavaScript & AJAX.
Comment: (0).
Trackbacks:(0).
Permalink
«Next post |
Previous post»




