[英]Reject the all other requests to reload the page except the first request
I have an issue in my project where i allow the first request ( one.jsp) to reload the page or redirect to a page , if there is a second request ( two.jsp) raised before the first request completed ( before loading one.jsppage ), then the second request should not be processed and it should be rejected. 我的项目中存在一个问题,如果在第一个请求完成之前(加载一个请求之前)提出了第二个请求(two.jsp),则我允许第一个请求(one.jsp)重新加载页面或重定向到页面。 jsppage),则不应处理第二个请求,并且应将其拒绝。
<pre>
<form id = "testform" action = "form.jsp">
<input type = "hidden" name = "testhidden" value = "">
</form>
<a href = "one.jsp"> First Request</a>
<a href = "two.jsp"> Second Request</a>
<a href = "javascript:document.getElementById('testform').submit();"> third Request</a>
<a onclick = "javascript:document.getElementById('testform').submit();"> fourth Request</a>
<button onclick = "javascript:document.getElementById('testform').submit();">fifth request</button>
</pre>
Actually, My requirement is that , if there a request to one page ( one.jsp) using tag or button onclick , then that page ( one.jsp) should get load, then rejected all other requests raised before loading page( one.jsp ). 实际上,我的要求是,如果使用标签或按钮onclick对一页(one.jsp)发出请求,则该页面(one.jsp)应该得到加载,然后拒绝加载页面(one.jsp)之前提出的所有其他请求。 )。 I am looking solution for this issue in javascript or jquery.
我正在使用javascript或jquery寻找此问题的解决方案。 Java is optional.
Java是可选的。 Any help would be greatly appreciated.
任何帮助将不胜感激。
Best way to restrict, you need to unbind click event on siblings , so once you clicked on first element other sibling elements will be disabled for click. 最好的限制方式是,您需要解除对兄弟姐妹的click事件的绑定 ,因此,一旦您单击第一个元素,其他兄弟姐妹元素将被禁用单击。 I just added parent element div#menu for simple access!
我刚刚添加了父元素div#menu以便于访问!
$('#menu a,#menu button').click(function(){
console.log("fire - "+$(this).text());
$(this).siblings().unbind('click');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.