我希望有人遇到过这个问题。我正在使用LightBox从服务器检索图像。使用URL请求中的参数在运行时创建图像。现在,这在所有浏览器中都可以正常工作。今天,我注意到Chrome浏览器两次发送了请求。 IE,FF和Safari不会这样做。
使用Chrome开发人员的工具的“网络”标签,我看到对服务器进行了两次调用,第一次是通过灯箱进行的,第二次是通过Jquery行7937进行的。使用相同的firefox工具,仅进行了一次调用。
从服务器端,我调试了它,它所做的只是通过OutputStream返回图像。它从Chrome调用了两次,但这只是因为chrome调用了两次。
任何想法为什么会这样做呢?任何想法,将不胜感激。
下面的代码
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js"></script>
<script type="text/javascript" src="http://localhost/dawn/AEIX/js/lightbox.js"></script>
<script type="text/javascript">
$("#display_id").click(function(e){
var urlGetString = $.param($('#mainform_id').serializeArray());
urlGetString = "http://localhost/show.do?" + urlGetString;
$("#display_id").attr("href", urlGetString);
});
</script>
</head>
<body>
<form name="mainform" id="mainform_id" action="http://localhost/report.do">
<!-- lots of input fields here -->
<a id="display_id" href="#" data-lightbox="histogram3">
<button type="button" class="button">DISPLAY</button>
</a>
</form>
</body>
</html>
最佳答案
一个非常有用的用户在GitHub上提供了解决方案。解决方案和用户信息可以在下面找到。
https://github.com/lokesh/lightbox2/issues/239#issuecomment-46556681
我在Chrome中尝试了该解决方案,现在可以正常使用了。它仅将数据发送到服务器一次。其余的浏览器仍然像以前一样工作。
关于javascript - Chrome使用两次Lightbox调用服务器,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24006699/