1

I am sending data using json when user does certain evens with the help of following code.

  console.log("   Ajax post");
  $.ajax({
    url: 'https://www.abc123.com/xyz',
    type: 'POST',
    dataType: 'json',
    data: {
      "md"   : qm["nd"],
      "url"  : ngurl,
      "data"   : sendpts
    },
    success: function(a){
        console.log("success");
        console.log(a.message);
    },
    error: function(request, status, error) {
        console.log("error");
    }
  }); 

Is there any way to send json data when the webpage gets closed along with the notification that the webpage was closed?

New to Rails
  • 2,754
  • 4
  • 24
  • 40
  • possible duplicate of [Is there any possibility how to send an AJAX after close the browser window?](http://stackoverflow.com/questions/6869393/is-there-any-possibility-how-to-send-an-ajax-after-close-the-browser-window) – JJJ Nov 12 '14 at 10:42
  • You can use the onbeforeunload event, but I don't think there will be enough time for you to send a request – Kroltan Nov 12 '14 at 10:42
  • window.onbeforeunload – Davor Zubak Nov 12 '14 at 10:43

0 Answers0