Paul Tomblin Paul Tomblin - 6 months ago 8
Javascript Question

Possible to make AJAX call that doesn't return?

Is it possible to send an jQuery.ajax call or equivalent without any sort of response? I want to trigger something on the server as I leave the page with the onbeforeunload command, but it's not something I need to feedback to the client, so I just want to send off the command and not wait for a response.

Is that possible?

Answer

Every request has a response. Even if the server throws an error a response is coming back with the error.

You can ignore the response if you like to just don't add a success callback.

$.ajax({
    url: "theURL",
    data: theData
});