What would cause a page to be canceled? I have a screenshot of the Chrome Developer Tools.
Chrome Version 33.0.1750.154 m consistently cancels image loads if I am using the Mobile Emulation pointed at my localhost; specifically with User Agent spoofing on (vs. just Screen settings).
When I turn User Agent spoofing off; image requests aren't canceled, I see the images.
I still don't understand why; in the former case, where the request is cancelled the Request Headers (CAUTION: Provisional headers are shown) have only
In the latter case, all of those plus others like:
Shrug
In my case, I found that it is jquery global timeout settings, a jquery plugin setup global timeout to 500ms, so that when the request exceed 500ms, chrome will cancel the request.
Another place we've encountered the (canceled)
status is in a particular TLS certificate misconfiguration. If a site such as https://www.example.com
is misconfigured such that the certificate does not include the www.
but is valid for https://example.com
, chrome will cancel this request and automatically redirect to the latter site. This is not the case for Firefox.
Currently valid example: https://www.pthree.org/
We had this problem having tag <button>
in the form, that was supposed to send ajax request from js. But this request was canceled, due to browser, that sends form automatically on any click on button
inside the form.
So if you realy want to use button
instead of regular div
or span
on the page, and you want to send form throw js - you should setup a listener with preventDefault
function.
e.g.
$('button').on('click', function(e){
e.preventDefault();
//do ajax
$.ajax({
...
});
})
I had the same issue when updating a record. Inside the save() i was prepping the rawdata taken from the form to match the database format (doing a lot of mapping of enums values, etc), and this intermittently cancels the put request. i resolved it by taking out the data prepping from the save() and creating a dedicated dataPrep() method out of it. I turned this dataPrep into async and await all the memory intensive data conversion. I then return the prepped data to the save() method that i could use in the http put client. I made sure i await on dataPrep() before calling the put method:
await dataToUpdate = await dataPrep(); http.put(apiUrl, dataToUpdate);
This solved the intermittent cancelling of request.
NB: Make sure you don't have any wrapping form elements.
I had a similar issue where my button with onclick={} was wrapped in a form element. When clicking the button the form is also submitted, and that messed it all up...
This answer will probably never be read by anyone, but I figured why not write it :)