0

I need to implement a cronjob functionality using my application, for this i try to use the ajax post so that it will not affect the page loading time. The problem that I am facing currently is if i need to open another url it happpens only after the successful of the ajax request.

Please anybody Suggest a solution for this.

Nobis
  • 23
  • 4

1 Answers1

0

Try to abort your ajax request before opening another url. Example with jQuery:

var request= $.ajax({
    url: "test.php"
}).done(function() {
    /* do something */
});

//kill the request
request.abort();

You could kill the request everytime a link is clicked, e.g:

$('a').on('click', function() {
    request.abort();
});

On the server side concurrent requests aren't queued. However if there is a file lock, e.g. when a php script opens a file for writing, concurrent requests to that file would be queued, and thus the execution of a php script would be stalled.

This has been discussed before: Simultaneous Requests to PHP Script

It seems that if you use file-based sessions in PHP each session_start(); would cause a file lock. So doing session_write_close(); after your work with the session is done would release that lock.

Community
  • 1
  • 1
Mario A
  • 3,286
  • 1
  • 17
  • 22
  • Thank you, in this whether the execution will stop? what i need is i just need to trigger an action and it has to be taken place in the background – Nobis Jan 17 '15 at 12:30
  • I also would like to know whether the web-server serializes the request. By disabling that will be a sloution – Nobis Jan 19 '15 at 06:13