Possible to make AJAX call that doesn't return?

前端 未结 4 1648
忘掉有多难
忘掉有多难 2020-12-30 11:57

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

4条回答
  •  梦毁少年i
    2020-12-30 12:53

    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
    });
    

提交回复
热议问题