IE7 appears to be caching the response from an ajax request. When the response is cached, it behaves as if the request is synchronous, calling my callback as soon as it is passed to jQuery.get, rather than waiting for the current call stack to return.
For now I'm going to put a short timeout in my callback, which will hopefully get my code to work at least. Is there a better way to prevent this from happening? To force IE7 to wait until the current call stack is finished before calling the callback?
Here's a simplified example of the behavior I'm seeing:
myDebugger.log("setting up ajax request");
jQuery.get(myUrl, function(){
myDebugger.log("ajax request returned")
});
myDebugger.log("finished setting up ajax request");
The first time I run this in IE7 after restarting the browser, I get:
setting up ajax request
finished setting up ajax request
ajax request returned
The second time I run this in IE7 I get this:
setting up ajax request
ajax request returned
finished setting up ajax request
Related
How can I catch all the AJAX requests that a page makes with a Webbrowser / EmbeddedWB? BeforeNavigate2 unfortunately isn't fired for AJAX requests.
For example: requests which are made when you type in google search bar.
If the environment is under your control. you can use a custom HTTP proxy (based on Indy for example).
See: Indy's TIdHTTPProxyServer: How to filter requests?
Ajax requests can be detected based on their specific header:
How to differentiate Ajax requests from normal Http requests?
Update: this question on the Microsoft web forum has an accepted answer:
AJAX detection in WebBrowser control
If I were you, I would've injected my own script into every page after it's been loaded. This a script that captures all AJAX requests and informs the application.
Using the following code, you may capture every AJAX request made by jQuery (Haven't tried, but I don't think it works for non-jQuery AJAX requests).
$.ajaxSetup({
beforeSend: function() {
// before sending the request
},
complete: function() {
// after request completion
}
});
It's not even a code, but it can give you a clue for what you want to do.
Surely using this method, you're gonna need to somehow communicate with your application. For instance, I'd use my made up protocol and a new window command so that my Delphi component will be able to capture and parse the event.
As I said there are plenty options here and I'm just giving a clue.
I send an AJAX request which returns a 302 (I see this using fiddler) but in firebug I never see the 302. I just see a 500.
Same thing happens with IE.
If an AJAX request returns a 302 do browsers swallow it?
Thanks
When performing an AJAX POST in my web application, I found that my browser was registering a 302 Found, followed by a 200 OK.
However, the JavaScript debugger showed the response as being a 200 OK, with the HTML content to be shown on the redirection page.
This demonstrates that the redirection is being handled internally by JavaScript. In this case, you could replace the page's content with that returned by the server's response.
document.open();
document.write(xhr.responseText);
document.close();
See this question for more details.
*update: sorry, i didn't give a context. I'm using Grails 2.1.2 with the spring security plugin installed. Js lib -> jQuery (latest)
I have a page that submits lots of synchronous ajax calls (not my design, sorry). After the 25th call i see from firebug that i start getting http 302 status, then the handler for ajax calls when there's no user session is called (loing/authAjax in my case). My particular handler sends an http 401. In any case why is the session expiring? This happens only when i submit tons of synchronous ajax calls. Is there any limit to the number of ajax calls? Is it documented anywhere? Making async calls is not an option in this case because these ajax calls make db updates on the same table and that would result in a hibernate lock exception.
I'm not asking for a fix, i know how to fix this (by doing one single ajax call). What i'm asking is why the session is being invalidated? Any ideas?
Did you try to set the cache setting to false in your calls with jQuery ?
302 means you're getting data from the browser cache instead of the server.
Hope this help....
I am making a ajax call in a page. Before getting the ajax response,
if user navigate to other page,
will the ajax call will be completed?
page loads
user doing some action, which making ajax call at
background and updating in server.
before ajax call gets response,user navigated to some other page.
Will that ajax call will be completed?
Thanks in Advance!!!
No. Whatever action the ajax call initiates on the server will probably finish (ie, the php script), but the browser will not receive the response.
I am sending an ajax request which is called on change event of a select box.Now what I want is that when a new request is sent to server, it will abort all the previous ajax requests as otherwise there will be a lot of ajax requests executing at the same time.I just want to execute only the latest request.
All help would be highly appreciable.
Abort Ajax requests using jQuery
Just store the XMLHttpRequests in an array and abort them one by one.