简体   繁体   English

拒绝所有其他请求以重新加载页面,第一个请求除外

[英]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>

FIDDLE 小提琴

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');

}); 

check the fiddle 检查小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在JR报告中除第一页之外的所有页面中删除表组件的表头? - How to remove the table header for table component in all the pages except first page in JR report? 在context.xml中设置上下文路径时,除第一页之外的所有页面上都有404错误 - 404 error on all pages except first page when setting context path in context.xml 浏览器是否为所有页面请求发送PAGE-REQUEST作为“GET”http方法? - Do browser send PAGE-REQUEST as “GET” http method for all page requests? Spring controller 如何每次只服务一个请求,并丢弃以相同方法收到的其他请求,直到第一个请求完成 - Spring controller how to serve only 1 request each time, and discard other requests received for the same method until first request has finished 删除除第一个使用递归之外的所有数字 - Remove all numbers except the first using recursion 删除除第一行以外的所有行-Java POI - Delete all rows except the first - Java POI 阻止所有项目,但ListView中的第一个元素除外 - Block all items, except the first element in ListView 如何在每个请求上重新加载jsp页面? - how to reload jsp page on every request? 互联网请求在第一时间有效,但对后续请求无效 - Internet request works the first time, but not on subsequent requests API请求除了一两个之外,如何添加拦截器? - How to add interceptor to all API requests except one or two?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM