Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5936227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:22:09+00:00 2026-05-22T15:22:09+00:00

When a user clicks a link, I would like to send an AJAX request

  • 0

When a user clicks a link, I would like to send an AJAX request to save the contents of the current page, and navigate away at the same time.

Typically the window is trying to navigate away, all AJAX requests get the “stop” button, but that may or may not mean that the server is processing the request. If the AJAX is aborted to soon, the changes will not be saved.

The valid readystates according to W3Schools

1: server connection established
2: request received
3: processing request
4: request finished and response is ready

I should I wait for number 2 or number 3 to ensure the request goes through on major browsers before navigating away?

I acknowledge the risk that by not confirming a successful save in number 4, I risk not letting the user know about a failure in saving changes,, But the code is very stable, so once the server receives the request, I am almost 100% sure that if the changes are not saved, the user will have no recourse anyway (post deleted or locked or something like that, and the changes are not that important anyway).

But the only problem is, if there is an Internet Connection Failure, I need to at least know about that failure in major browsers.

Do I have to wait for number 4 to know about that?

Assuming I don’t even care about connection failures, which one should I wait for?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:22:10+00:00Added an answer on May 22, 2026 at 3:22 pm

    Yes wait for 4 and check the response. You could pass back something from your server in the POST / GET to say success, then change window.location. Be sure to preventDefault if you’re clicking a link to trigger your ajax.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to record every time a registered user clicks a link and
When a user clicks on an image on a web page, I'd like to
Is it possible to block a page when a user clicks on a link
In a fictitious web application ... The user clicks a link The server starts
When a user have changed something in a form, then clicks on any link
I want to make a link on a page that when clicked, would open
I am trying to send the UIWebView page Title to UINavigationBar. I would also
I would like to be able to send my users a url such as
In my Django 1.2.4 site, I would like to direct the user to an
I would like to have a page that would contain: hyperlik Add new country.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.