I have a long service call that I am calling with jQuery.ajax. The service may take more than 2 minutes.
An AJAX request is submitted and no response is expected. A separate AJAX request reports progress.
On some sites, we found that after 2 minutes the agent resubmitted the Ajax request. Chrome browser, but I doubt the problem is with Chrome.
This is not the case when we resubmit an ajax request. To make sure we set bool to prevent re-sending to the beforeSend event.
The way I handle this forwarding now is to add nonce to the data request and check the service if nonce has already been sent before its operation. Any second call to this service returns harmlessly and the original request continues to evolve.
Please note that I added a useless service that does nothing but wait for 5 minutes, and have never experienced a problem with a test service (on production sites).
Can someone give me any clues as to what causes this ajax re-presentation, and how to do this in order to play it locally?
This is js used to send the request:
var sent = false;
var data = { ... };
$.ajax("service.ashx?loc=area/subarea/", {
type: "POST",
data: data,
traditional: true,
error: function (jqXHR, textStatus, errorThrown) {
if (jqXHR.status === 0) {
} else {
ReportFailure(textStatus,errorThrown);
}
},
beforeSend: function () {
if (sent === true) {
return false;
}
sent = true;
return true;
}
});
Here is ajax requested in an HTTP archive (HAR) where the request was resubmitted and it instantly failed. Pay attention to the 2 minute time.
{
"startedDateTime": "2015-12-11T12:26:58.018Z",
"time": 120066.61499999973,
"request": {
"method": "POST",
"url": "https://example.com/service.ashx?loc=area/subarea/",
"httpVersion": "HTTP/1.1",
"headers": [
... // removed for brevity
],
"queryString": [
{ "name": "loc", "value": "area/subarea/" }
],
"cookies": [
... // removed for brevity
],
"headersSize": 1163,
"bodySize": 48048,
"postData": {
"mimeType": "application/x-www-form-urlencoded; charset=UTF-8",
"text": ..., // removed for brevity
"params": [
... // removed for brevity ] }
},
"response": {
"status": 500,
"statusText": "Internal Server Error",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Date",
"value": "Fri, 11 Dec 2015 12:28:57 GMT"
},
... // removed for brevity
],
"cookies": [],
"content": {
"size": 54,
"mimeType": "text/xml",
"compression": 0
},
"redirectURL": "",
"headersSize": 305,
"bodySize": 54,
"_transferSize": 359
},
"cache": {},
"timings": {
"blocked": 120005.055999998,
"dns": -1,
"connect": -1,
"send": 1.0939999989932403,
"wait": 59.986000001008506,
"receive": 0.47900000172376167,
"ssl": -1
},
"connection": "7498"