Why ajax cancel? - ajax

on some pages that not defined at router some requests canceled. But on other pages all is fine. chrome://net-internals/#events

Related

Safari sends fetch ajax requests on url bar autofilled

my client side react app is running on http://localhost:3000 and my node js server is running on http://localhost:8080. When client url is loaded, it sends GET /auth/user 304 0.494 ms - - fetch ajax request to load user(on react componentDidMount function). Problem is, when typing 'l' on Safari browser and url is autofilled with 'http://localhost:3000', it is confirmed that my server get the same request as GET /auth/user, before I even press enter key and before the client page is loaded. In Chrome it doesn't. Why Safari browser sends ajax request when user didn't visit the page and just typed part of its url? Is it a designed behavior?
As a result of tracking the reason for 6 hours. I figured out Safari implements cached ajax request differently from other web browsers. When Safari has client url data which has records of requesting ajax to external api, Safari sends the same ajax request just before user visits the client url page(when url is being typed and auto-suggested) to check if the response is 200(different) or 304(same). If the response is 304(same) and client page is loaded actually, Safari doesn't send ajax request again. This can be very annoying in the user login process, because the user data is loaded before actual authentication process is complete(user data response is 304), so client app remains unauthenticated when browser is authenticated. The solution I landed was adding an extra query parameter when fetching user data( '${root}/auth/user?' + 'nocache= new Date.getTime()' ) to prevent Caching AJAX in Safari browser. Hope it helps someone who faces the same problem.

Why do my website's post-page-load Ajax calls fail in the Facebook In-App Browser?

My website uses Ajax to report the user's progress back to the server while the user stays on the same webpage. This works fine on all browsers except the Facebook In-App Browser (FB IAB). Why?
If your web server uses cookies when processing Ajax requests, you will have the following problem:
After a web page loads, FB IAB doesn't send cookies to the server for Ajax calls. I consider this a bug.
A workaround is to send all required data in the querystring instead.

Expire Page after page submit in MVC

Is there a way to expire a form after the user presses submit and redirected to another external url.
I want to restrain the user from clicking the browser's back button and resubmit the form.
I have tried to set NoCache and NoStore in the Controller but the browser still held in cache (Chrome).
This has nothing to do with MVC, the cache, or your browser; this is how HTTP headers handle POST requests.
Normally, when submitting a form to an internal or external URL you can avoid POST data being resubmitted by issuing a 302 "Moved Temporarily" redirect after you've processed the data, or by sending the request with AJAX or cURL.
There are multiple examples with answers on Stack Overflow, simply search for "prevent form resubmission"

Is it smart to load dynamic (text+media) content via websocket?

Say I have a web page, and it has a websocket chat running on it. Now, my plan is, when the user clicks on any of the links of the page, the page is not refreshed. Instead, I send the request to the websocket (the same one on which the chat is running), and it returns the new page.
So, is this a good idea? Or should I go for Ajax?
Ajax would be easier. You don't need branching inside the chat websocket listener this way, just request the needed page and put the response into the page body.

ajax call and page redirection

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.

Resources