Possible to make AJAX call that doesn't return?

前端 未结 4 1669
忘掉有多难
忘掉有多难 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条回答
  •  长情又很酷
    2020-12-30 12:36

    Assuming you're using something like this:

    $.ajax({
       url: "test.html",
       context: document.body
    })
    

    (borrowed from http://api.jquery.com/jQuery.ajax/ and edited), you can discard the response.

提交回复
热议问题