Send an Ajax Call on beforeunload/unload





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







-1















Scenario: I am creating an event registration module in which a user would choose a date from a calendar for booking, fill some input fields and pay up to book the date.
One of the requirements is that, there can be only one booking per date.
This arises a case where two people want to book the same date on the same time. So, we need to show the user who came later to book the date a message that a booking is already in progress for that specific date. Please check back later.



For this to achieve, I am creating a temporary entry in my DB whenever a user chooses a date. Against that entry, I can show the message to the other user who came later.



Logically, that entry has to be deleted if the first user:




  1. selects some other date.

  2. closes his browser or navigate away from the page


So that it would be available for the second user who wants to book for the same date.



The Problem: I am able to delete the entry once a user changes his selected date. I am not able to achieve the second one. I wrote a function that will delete the row and calling that function onbeforeunload jQuery event. Apparently, that function is not working with jQuery.



window.onbeforeunload = function(){
deleteTempEntry(); //This sends an ajax call to delete the entry. Not working.

alert("The second alert"); // even this alert doesn't work.

// I actually intend to use confirm box to make sure to not to delete the entry if the user does not leave the page.
confirm("Your current progress will be removed. Are you sure?");

//Calling this return function shows the warning message but none of the other code works.
//return 'Are you sure you want to leave?';
};


I tried, bind/on/pure JS but none of those seem to work.



As explained here, there isn't really much I can do with onbeforeunload/unload events because of the security reasons.
Any workaround for this?



Thanks.










share|improve this question

























  • how about a opening a new window ? then show your messages there, and the unload on the popup should trigger the deleteTempEntry()

    – Paul John Diwa
    Apr 6 '17 at 7:30













  • So, there is not much you can do on the front-end when the user is closing the tab/browser. So you will have to maintain a timeout function on the backend, so that it deletes the incomplete registration.

    – MegaMind
    Apr 6 '17 at 7:33


















-1















Scenario: I am creating an event registration module in which a user would choose a date from a calendar for booking, fill some input fields and pay up to book the date.
One of the requirements is that, there can be only one booking per date.
This arises a case where two people want to book the same date on the same time. So, we need to show the user who came later to book the date a message that a booking is already in progress for that specific date. Please check back later.



For this to achieve, I am creating a temporary entry in my DB whenever a user chooses a date. Against that entry, I can show the message to the other user who came later.



Logically, that entry has to be deleted if the first user:




  1. selects some other date.

  2. closes his browser or navigate away from the page


So that it would be available for the second user who wants to book for the same date.



The Problem: I am able to delete the entry once a user changes his selected date. I am not able to achieve the second one. I wrote a function that will delete the row and calling that function onbeforeunload jQuery event. Apparently, that function is not working with jQuery.



window.onbeforeunload = function(){
deleteTempEntry(); //This sends an ajax call to delete the entry. Not working.

alert("The second alert"); // even this alert doesn't work.

// I actually intend to use confirm box to make sure to not to delete the entry if the user does not leave the page.
confirm("Your current progress will be removed. Are you sure?");

//Calling this return function shows the warning message but none of the other code works.
//return 'Are you sure you want to leave?';
};


I tried, bind/on/pure JS but none of those seem to work.



As explained here, there isn't really much I can do with onbeforeunload/unload events because of the security reasons.
Any workaround for this?



Thanks.










share|improve this question

























  • how about a opening a new window ? then show your messages there, and the unload on the popup should trigger the deleteTempEntry()

    – Paul John Diwa
    Apr 6 '17 at 7:30













  • So, there is not much you can do on the front-end when the user is closing the tab/browser. So you will have to maintain a timeout function on the backend, so that it deletes the incomplete registration.

    – MegaMind
    Apr 6 '17 at 7:33














-1












-1








-1








Scenario: I am creating an event registration module in which a user would choose a date from a calendar for booking, fill some input fields and pay up to book the date.
One of the requirements is that, there can be only one booking per date.
This arises a case where two people want to book the same date on the same time. So, we need to show the user who came later to book the date a message that a booking is already in progress for that specific date. Please check back later.



For this to achieve, I am creating a temporary entry in my DB whenever a user chooses a date. Against that entry, I can show the message to the other user who came later.



Logically, that entry has to be deleted if the first user:




  1. selects some other date.

  2. closes his browser or navigate away from the page


So that it would be available for the second user who wants to book for the same date.



The Problem: I am able to delete the entry once a user changes his selected date. I am not able to achieve the second one. I wrote a function that will delete the row and calling that function onbeforeunload jQuery event. Apparently, that function is not working with jQuery.



window.onbeforeunload = function(){
deleteTempEntry(); //This sends an ajax call to delete the entry. Not working.

alert("The second alert"); // even this alert doesn't work.

// I actually intend to use confirm box to make sure to not to delete the entry if the user does not leave the page.
confirm("Your current progress will be removed. Are you sure?");

//Calling this return function shows the warning message but none of the other code works.
//return 'Are you sure you want to leave?';
};


I tried, bind/on/pure JS but none of those seem to work.



As explained here, there isn't really much I can do with onbeforeunload/unload events because of the security reasons.
Any workaround for this?



Thanks.










share|improve this question
















Scenario: I am creating an event registration module in which a user would choose a date from a calendar for booking, fill some input fields and pay up to book the date.
One of the requirements is that, there can be only one booking per date.
This arises a case where two people want to book the same date on the same time. So, we need to show the user who came later to book the date a message that a booking is already in progress for that specific date. Please check back later.



For this to achieve, I am creating a temporary entry in my DB whenever a user chooses a date. Against that entry, I can show the message to the other user who came later.



Logically, that entry has to be deleted if the first user:




  1. selects some other date.

  2. closes his browser or navigate away from the page


So that it would be available for the second user who wants to book for the same date.



The Problem: I am able to delete the entry once a user changes his selected date. I am not able to achieve the second one. I wrote a function that will delete the row and calling that function onbeforeunload jQuery event. Apparently, that function is not working with jQuery.



window.onbeforeunload = function(){
deleteTempEntry(); //This sends an ajax call to delete the entry. Not working.

alert("The second alert"); // even this alert doesn't work.

// I actually intend to use confirm box to make sure to not to delete the entry if the user does not leave the page.
confirm("Your current progress will be removed. Are you sure?");

//Calling this return function shows the warning message but none of the other code works.
//return 'Are you sure you want to leave?';
};


I tried, bind/on/pure JS but none of those seem to work.



As explained here, there isn't really much I can do with onbeforeunload/unload events because of the security reasons.
Any workaround for this?



Thanks.







javascript php jquery ajax date






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 23 '17 at 12:18









Community

11




11










asked Apr 6 '17 at 7:23









Awais UmarAwais Umar

1,13631532




1,13631532













  • how about a opening a new window ? then show your messages there, and the unload on the popup should trigger the deleteTempEntry()

    – Paul John Diwa
    Apr 6 '17 at 7:30













  • So, there is not much you can do on the front-end when the user is closing the tab/browser. So you will have to maintain a timeout function on the backend, so that it deletes the incomplete registration.

    – MegaMind
    Apr 6 '17 at 7:33



















  • how about a opening a new window ? then show your messages there, and the unload on the popup should trigger the deleteTempEntry()

    – Paul John Diwa
    Apr 6 '17 at 7:30













  • So, there is not much you can do on the front-end when the user is closing the tab/browser. So you will have to maintain a timeout function on the backend, so that it deletes the incomplete registration.

    – MegaMind
    Apr 6 '17 at 7:33

















how about a opening a new window ? then show your messages there, and the unload on the popup should trigger the deleteTempEntry()

– Paul John Diwa
Apr 6 '17 at 7:30







how about a opening a new window ? then show your messages there, and the unload on the popup should trigger the deleteTempEntry()

– Paul John Diwa
Apr 6 '17 at 7:30















So, there is not much you can do on the front-end when the user is closing the tab/browser. So you will have to maintain a timeout function on the backend, so that it deletes the incomplete registration.

– MegaMind
Apr 6 '17 at 7:33





So, there is not much you can do on the front-end when the user is closing the tab/browser. So you will have to maintain a timeout function on the backend, so that it deletes the incomplete registration.

– MegaMind
Apr 6 '17 at 7:33












3 Answers
3






active

oldest

votes


















2














You can post data with async: false like this:



$(window).unload(function () {
$.ajax({
type: 'POST',
async: false,
url: 'your url',
data: { }
});
});





share|improve this answer
























  • Can you please explain how would it work?

    – Awais Umar
    Apr 6 '17 at 9:05











  • synchronous request will cause the browser to become un-responsive until the request is complete.

    – Majid Parvin
    Apr 6 '17 at 10:03











  • It is a syncrhonous call that is being made, so it blocks further code execution untill the request has finished.

    – Jesse Schokker
    Apr 6 '17 at 10:04






  • 1





    you're right but you are leaving the page. don't you? it doesn't matter.

    – Majid Parvin
    Apr 6 '17 at 10:06













  • could you resolve your problem?

    – Majid Parvin
    Apr 6 '17 at 10:39



















2














Try console.log and return in your onbeforeunload method. maybe user leaves the page before your ajax goes through.



See:
https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload



Since 25 May 2011, the HTML5 specification states that calls to




  • window.alert()

  • window.confirm()

  • window.prompt()


commands may be ignored during this event.






share|improve this answer


























  • I understand that. That's why I planned to use confirm method so to make sure the ajax request goes. But confirm(), alertI(), they don't work.

    – Awais Umar
    Apr 6 '17 at 9:03











  • @Symbolwdd - im not sure about this but, try to send an ajax in the beforeunload function and return null to it from response of ajax. again, not sure, just trying to give an idea. since the beforeunload prompt triggers when this method is returned a value.

    – Sahal Tariq
    Apr 6 '17 at 9:14











  • Thank you for the documentation. Looks like onbeforeunload is not on the table anymore. I'll have to shift to cron job in that case.

    – Awais Umar
    Apr 8 '17 at 9:03



















0














You can make the client send out a "heartbeat" every 30 seconds or so to the server, and update a record in the database with a timestamp of the last sent heartbeat along with a reference to the booking date. Then run a cronjob which runs every minute or so, which checks all of those records, and if one of them is over let's say over 120 seconds old, then delete the record.






share|improve this answer
























  • It makes sense. But we actually have given a user, 20min timespan to complete the form and do the transaction. After that, the session will expire. Combined with that requirement, applying the approach you have suggested would cause problem unfortunately.

    – Awais Umar
    Apr 6 '17 at 9:04











  • You can extend the timeout. This probaly is the only solution that is reliable, which you need as it is a important part of your system.

    – Jesse Schokker
    Apr 6 '17 at 10:02












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43248362%2fsend-an-ajax-call-on-beforeunload-unload%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














You can post data with async: false like this:



$(window).unload(function () {
$.ajax({
type: 'POST',
async: false,
url: 'your url',
data: { }
});
});





share|improve this answer
























  • Can you please explain how would it work?

    – Awais Umar
    Apr 6 '17 at 9:05











  • synchronous request will cause the browser to become un-responsive until the request is complete.

    – Majid Parvin
    Apr 6 '17 at 10:03











  • It is a syncrhonous call that is being made, so it blocks further code execution untill the request has finished.

    – Jesse Schokker
    Apr 6 '17 at 10:04






  • 1





    you're right but you are leaving the page. don't you? it doesn't matter.

    – Majid Parvin
    Apr 6 '17 at 10:06













  • could you resolve your problem?

    – Majid Parvin
    Apr 6 '17 at 10:39
















2














You can post data with async: false like this:



$(window).unload(function () {
$.ajax({
type: 'POST',
async: false,
url: 'your url',
data: { }
});
});





share|improve this answer
























  • Can you please explain how would it work?

    – Awais Umar
    Apr 6 '17 at 9:05











  • synchronous request will cause the browser to become un-responsive until the request is complete.

    – Majid Parvin
    Apr 6 '17 at 10:03











  • It is a syncrhonous call that is being made, so it blocks further code execution untill the request has finished.

    – Jesse Schokker
    Apr 6 '17 at 10:04






  • 1





    you're right but you are leaving the page. don't you? it doesn't matter.

    – Majid Parvin
    Apr 6 '17 at 10:06













  • could you resolve your problem?

    – Majid Parvin
    Apr 6 '17 at 10:39














2












2








2







You can post data with async: false like this:



$(window).unload(function () {
$.ajax({
type: 'POST',
async: false,
url: 'your url',
data: { }
});
});





share|improve this answer













You can post data with async: false like this:



$(window).unload(function () {
$.ajax({
type: 'POST',
async: false,
url: 'your url',
data: { }
});
});






share|improve this answer












share|improve this answer



share|improve this answer










answered Apr 6 '17 at 8:07









Majid ParvinMajid Parvin

1,60731330




1,60731330













  • Can you please explain how would it work?

    – Awais Umar
    Apr 6 '17 at 9:05











  • synchronous request will cause the browser to become un-responsive until the request is complete.

    – Majid Parvin
    Apr 6 '17 at 10:03











  • It is a syncrhonous call that is being made, so it blocks further code execution untill the request has finished.

    – Jesse Schokker
    Apr 6 '17 at 10:04






  • 1





    you're right but you are leaving the page. don't you? it doesn't matter.

    – Majid Parvin
    Apr 6 '17 at 10:06













  • could you resolve your problem?

    – Majid Parvin
    Apr 6 '17 at 10:39



















  • Can you please explain how would it work?

    – Awais Umar
    Apr 6 '17 at 9:05











  • synchronous request will cause the browser to become un-responsive until the request is complete.

    – Majid Parvin
    Apr 6 '17 at 10:03











  • It is a syncrhonous call that is being made, so it blocks further code execution untill the request has finished.

    – Jesse Schokker
    Apr 6 '17 at 10:04






  • 1





    you're right but you are leaving the page. don't you? it doesn't matter.

    – Majid Parvin
    Apr 6 '17 at 10:06













  • could you resolve your problem?

    – Majid Parvin
    Apr 6 '17 at 10:39

















Can you please explain how would it work?

– Awais Umar
Apr 6 '17 at 9:05





Can you please explain how would it work?

– Awais Umar
Apr 6 '17 at 9:05













synchronous request will cause the browser to become un-responsive until the request is complete.

– Majid Parvin
Apr 6 '17 at 10:03





synchronous request will cause the browser to become un-responsive until the request is complete.

– Majid Parvin
Apr 6 '17 at 10:03













It is a syncrhonous call that is being made, so it blocks further code execution untill the request has finished.

– Jesse Schokker
Apr 6 '17 at 10:04





It is a syncrhonous call that is being made, so it blocks further code execution untill the request has finished.

– Jesse Schokker
Apr 6 '17 at 10:04




1




1





you're right but you are leaving the page. don't you? it doesn't matter.

– Majid Parvin
Apr 6 '17 at 10:06







you're right but you are leaving the page. don't you? it doesn't matter.

– Majid Parvin
Apr 6 '17 at 10:06















could you resolve your problem?

– Majid Parvin
Apr 6 '17 at 10:39





could you resolve your problem?

– Majid Parvin
Apr 6 '17 at 10:39













2














Try console.log and return in your onbeforeunload method. maybe user leaves the page before your ajax goes through.



See:
https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload



Since 25 May 2011, the HTML5 specification states that calls to




  • window.alert()

  • window.confirm()

  • window.prompt()


commands may be ignored during this event.






share|improve this answer


























  • I understand that. That's why I planned to use confirm method so to make sure the ajax request goes. But confirm(), alertI(), they don't work.

    – Awais Umar
    Apr 6 '17 at 9:03











  • @Symbolwdd - im not sure about this but, try to send an ajax in the beforeunload function and return null to it from response of ajax. again, not sure, just trying to give an idea. since the beforeunload prompt triggers when this method is returned a value.

    – Sahal Tariq
    Apr 6 '17 at 9:14











  • Thank you for the documentation. Looks like onbeforeunload is not on the table anymore. I'll have to shift to cron job in that case.

    – Awais Umar
    Apr 8 '17 at 9:03
















2














Try console.log and return in your onbeforeunload method. maybe user leaves the page before your ajax goes through.



See:
https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload



Since 25 May 2011, the HTML5 specification states that calls to




  • window.alert()

  • window.confirm()

  • window.prompt()


commands may be ignored during this event.






share|improve this answer


























  • I understand that. That's why I planned to use confirm method so to make sure the ajax request goes. But confirm(), alertI(), they don't work.

    – Awais Umar
    Apr 6 '17 at 9:03











  • @Symbolwdd - im not sure about this but, try to send an ajax in the beforeunload function and return null to it from response of ajax. again, not sure, just trying to give an idea. since the beforeunload prompt triggers when this method is returned a value.

    – Sahal Tariq
    Apr 6 '17 at 9:14











  • Thank you for the documentation. Looks like onbeforeunload is not on the table anymore. I'll have to shift to cron job in that case.

    – Awais Umar
    Apr 8 '17 at 9:03














2












2








2







Try console.log and return in your onbeforeunload method. maybe user leaves the page before your ajax goes through.



See:
https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload



Since 25 May 2011, the HTML5 specification states that calls to




  • window.alert()

  • window.confirm()

  • window.prompt()


commands may be ignored during this event.






share|improve this answer















Try console.log and return in your onbeforeunload method. maybe user leaves the page before your ajax goes through.



See:
https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload



Since 25 May 2011, the HTML5 specification states that calls to




  • window.alert()

  • window.confirm()

  • window.prompt()


commands may be ignored during this event.







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 4 at 2:39









ClickThisNick

2,08082550




2,08082550










answered Apr 6 '17 at 7:52









Sahal TariqSahal Tariq

14819




14819













  • I understand that. That's why I planned to use confirm method so to make sure the ajax request goes. But confirm(), alertI(), they don't work.

    – Awais Umar
    Apr 6 '17 at 9:03











  • @Symbolwdd - im not sure about this but, try to send an ajax in the beforeunload function and return null to it from response of ajax. again, not sure, just trying to give an idea. since the beforeunload prompt triggers when this method is returned a value.

    – Sahal Tariq
    Apr 6 '17 at 9:14











  • Thank you for the documentation. Looks like onbeforeunload is not on the table anymore. I'll have to shift to cron job in that case.

    – Awais Umar
    Apr 8 '17 at 9:03



















  • I understand that. That's why I planned to use confirm method so to make sure the ajax request goes. But confirm(), alertI(), they don't work.

    – Awais Umar
    Apr 6 '17 at 9:03











  • @Symbolwdd - im not sure about this but, try to send an ajax in the beforeunload function and return null to it from response of ajax. again, not sure, just trying to give an idea. since the beforeunload prompt triggers when this method is returned a value.

    – Sahal Tariq
    Apr 6 '17 at 9:14











  • Thank you for the documentation. Looks like onbeforeunload is not on the table anymore. I'll have to shift to cron job in that case.

    – Awais Umar
    Apr 8 '17 at 9:03

















I understand that. That's why I planned to use confirm method so to make sure the ajax request goes. But confirm(), alertI(), they don't work.

– Awais Umar
Apr 6 '17 at 9:03





I understand that. That's why I planned to use confirm method so to make sure the ajax request goes. But confirm(), alertI(), they don't work.

– Awais Umar
Apr 6 '17 at 9:03













@Symbolwdd - im not sure about this but, try to send an ajax in the beforeunload function and return null to it from response of ajax. again, not sure, just trying to give an idea. since the beforeunload prompt triggers when this method is returned a value.

– Sahal Tariq
Apr 6 '17 at 9:14





@Symbolwdd - im not sure about this but, try to send an ajax in the beforeunload function and return null to it from response of ajax. again, not sure, just trying to give an idea. since the beforeunload prompt triggers when this method is returned a value.

– Sahal Tariq
Apr 6 '17 at 9:14













Thank you for the documentation. Looks like onbeforeunload is not on the table anymore. I'll have to shift to cron job in that case.

– Awais Umar
Apr 8 '17 at 9:03





Thank you for the documentation. Looks like onbeforeunload is not on the table anymore. I'll have to shift to cron job in that case.

– Awais Umar
Apr 8 '17 at 9:03











0














You can make the client send out a "heartbeat" every 30 seconds or so to the server, and update a record in the database with a timestamp of the last sent heartbeat along with a reference to the booking date. Then run a cronjob which runs every minute or so, which checks all of those records, and if one of them is over let's say over 120 seconds old, then delete the record.






share|improve this answer
























  • It makes sense. But we actually have given a user, 20min timespan to complete the form and do the transaction. After that, the session will expire. Combined with that requirement, applying the approach you have suggested would cause problem unfortunately.

    – Awais Umar
    Apr 6 '17 at 9:04











  • You can extend the timeout. This probaly is the only solution that is reliable, which you need as it is a important part of your system.

    – Jesse Schokker
    Apr 6 '17 at 10:02
















0














You can make the client send out a "heartbeat" every 30 seconds or so to the server, and update a record in the database with a timestamp of the last sent heartbeat along with a reference to the booking date. Then run a cronjob which runs every minute or so, which checks all of those records, and if one of them is over let's say over 120 seconds old, then delete the record.






share|improve this answer
























  • It makes sense. But we actually have given a user, 20min timespan to complete the form and do the transaction. After that, the session will expire. Combined with that requirement, applying the approach you have suggested would cause problem unfortunately.

    – Awais Umar
    Apr 6 '17 at 9:04











  • You can extend the timeout. This probaly is the only solution that is reliable, which you need as it is a important part of your system.

    – Jesse Schokker
    Apr 6 '17 at 10:02














0












0








0







You can make the client send out a "heartbeat" every 30 seconds or so to the server, and update a record in the database with a timestamp of the last sent heartbeat along with a reference to the booking date. Then run a cronjob which runs every minute or so, which checks all of those records, and if one of them is over let's say over 120 seconds old, then delete the record.






share|improve this answer













You can make the client send out a "heartbeat" every 30 seconds or so to the server, and update a record in the database with a timestamp of the last sent heartbeat along with a reference to the booking date. Then run a cronjob which runs every minute or so, which checks all of those records, and if one of them is over let's say over 120 seconds old, then delete the record.







share|improve this answer












share|improve this answer



share|improve this answer










answered Apr 6 '17 at 7:28









Jesse SchokkerJesse Schokker

640518




640518













  • It makes sense. But we actually have given a user, 20min timespan to complete the form and do the transaction. After that, the session will expire. Combined with that requirement, applying the approach you have suggested would cause problem unfortunately.

    – Awais Umar
    Apr 6 '17 at 9:04











  • You can extend the timeout. This probaly is the only solution that is reliable, which you need as it is a important part of your system.

    – Jesse Schokker
    Apr 6 '17 at 10:02



















  • It makes sense. But we actually have given a user, 20min timespan to complete the form and do the transaction. After that, the session will expire. Combined with that requirement, applying the approach you have suggested would cause problem unfortunately.

    – Awais Umar
    Apr 6 '17 at 9:04











  • You can extend the timeout. This probaly is the only solution that is reliable, which you need as it is a important part of your system.

    – Jesse Schokker
    Apr 6 '17 at 10:02

















It makes sense. But we actually have given a user, 20min timespan to complete the form and do the transaction. After that, the session will expire. Combined with that requirement, applying the approach you have suggested would cause problem unfortunately.

– Awais Umar
Apr 6 '17 at 9:04





It makes sense. But we actually have given a user, 20min timespan to complete the form and do the transaction. After that, the session will expire. Combined with that requirement, applying the approach you have suggested would cause problem unfortunately.

– Awais Umar
Apr 6 '17 at 9:04













You can extend the timeout. This probaly is the only solution that is reliable, which you need as it is a important part of your system.

– Jesse Schokker
Apr 6 '17 at 10:02





You can extend the timeout. This probaly is the only solution that is reliable, which you need as it is a important part of your system.

– Jesse Schokker
Apr 6 '17 at 10:02


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43248362%2fsend-an-ajax-call-on-beforeunload-unload%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas