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

  • SEARCH
  • Home
  • 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 6804447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:28:00+00:00 2026-05-26T19:28:00+00:00

I found that this works sporadically, but usually doesn’t work at all. $(window).unload(function() {

  • 0

I found that this works sporadically, but usually doesn’t work at all.

$(window).unload(function()
{
    $.ajax
    ({
        url: "script.php",
        type: "POST",
        data: 
        { 
            value: value
        }
    });
});

Setting the async to false (i.e.'async' : false) does get around the problem and executes the php script every time. But depending on the script, it can freeze the browser up for a while.

Is there a good way of sending data to a php script and having the server execute it without the user waiting for a response?

EDIT – My understanding of client-server interaction is rusty, but it’s not the request sending that’s taking a long time, it’s the processing of the data sent by the request. I’m wondering if that processing can occur without the user having to be on the page at all.

  • 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-26T19:28:01+00:00Added an answer on May 26, 2026 at 7:28 pm

    You would need to accomplish this on the server side by closing the connection and then continuing to process the data. In php it would look something like this:

    <?php
      header("Content-Length: 0");
      header("Connection: close");
      flush();
    
     //At this point the request is finished and you can continue to process the data. 
     //Keep in mind the connection is now closed and you can no longer return any information to the user.
    

    ?>

    Note this isn’t technically firing a background task so you should be fine doing this on a shared host. Just as long as it doesn’t hang for an exceptionally long period of time.

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

Sidebar

Related Questions

Searching here I found that this question was already asked , but I think
This morning, I tried to commit a revision to Subversion and found that all
In an app I'm profiling, I found that in some scenarios this function is
I found this question that is discussing what I would like to do, but
I'm working with the SysUtils.Format function and variant values, and I found that this
I found that this C++ code: vector<int> a; a.push_back(1); a.push_back(2); vector<int>::iterator it = a.begin();
I was creating a website http://tapasya.co.in and i found that this site has some
While trying to answer this question I found that the code int* p =
I'm attempting to use code I've found that uses Win32. However, I'm getting this
I had posted a question in regards to this code. I found that JTextArea

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.