Jump to content

[SOLVED] onLoading some AJAX


sKunKbad

Recommended Posts

If I send an AJAX request to a php script as a page loads, and the user exits the page before the php script is done processing what it is doing, it should still do what it needs to do right?

 

I've got a cURL script that adds users to a email database, but it runs slow (2 seconds) and I want to do it without the user seeing the lag. My plan would be to have the user see the "thank you" message while the cURL script is running in the background. I'm just concerned that if they see the thank you message and exit the page that the AJAX request would be interrupted.

Link to comment
https://forums.phpfreaks.com/topic/78265-solved-onloading-some-ajax/
Share on other sites

It works fine in case anybody ever wants to know. I used a javascript detection in previous pages to make sure that PHP knows to either use the ajax type HTTPrequest or cURL script directly.

 

As a side note, I couldn't find any javascript detection tutorials out there. What I ended up doing is setting a cookie with javascript, and then checking to see if it exists in php. If php sees the cookie set by javascript, it turns it into a session variable. When the user finally gets to the page that needs to know if javascript is enabled or not, php dishes out the correct code for the situation.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.