开发者

How to invoke xforms submission from java script

开发者 https://www.devze.com 2023-02-20 23:54 出处:网络
I would like to submit my xform when i click on the browser close button also. To achieve that i have written body unload function which is called when the browser is closed开发者_JAVA百科.

I would like to submit my xform when i click on the browser close button also.

To achieve that i have written body unload function which is called when the browser is closed开发者_JAVA百科.

Now from this java script function i want to call the xforms submit

<xhtml:body class="MainBODY" onunload="browserClose()">

Please suggest some way to do the same.


Unfortunately (or not depending on how you look at it), you can't reliably call a service (make an Ajax request) in onbeforeunload. When the user navigates away from your page, you can run some JavaScript, and that JavaScript can issue an Ajax request, but the browser won't wait for the response and there is a chance that the request doesn't even make it to the server.

So the best you can do is to issue an alert to users, which gives them a chance not to leave the form, for instance to save data they just entered and that otherwise might be lost. See how to alert users leaving a form without saving for more on this.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号