jQuery ajax 在 IE 中不起作用
我在 WebLogic 10.3.2 上运行的 Web 应用程序中使用 jQuery 1.7.1。我对服务器进行 ajax GET 操作。这一切在 FF 和 Chrome 中工作正常,但 IE 8 中的 ajax 事件没有任何反应。就好像文档准备根本没有设置它们一样。
这是一些js:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="css/messaging.css" />
<link rel="stylesheet" type="text/css" href="css/jquery-ui-1.8.17.custom.css" />
<link rel="stylesheet" type="text/css" href="css/ui.dynatree.css" />
<link rel="stylesheet" type="text/css" href="css/jquery.cluetip.css" />
<link rel="stylesheet" type="text/css" href="css/jquery-ui-timepicker-addon.css" />
<script type="text/javascript" src="js/jquery-1.7.1.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript" src="js/jquery.dynatree.js"></script>
<script type="text/javascript" src="js/jquery.cookies.2.2.0.js"></script>
<script type="text/javascript" src="js/jquery.cluetip.js"></script>
<script type="text/javascript" src="js/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="js/jquery-ui-sliderAccess.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$.ajaxSetup ({
cache: false,
xhrFields: {
withCredentials: true
},
crossDomain: true
});
...
$('#findSites').click(function() { // Locate HTML DOM element with ID "somebutton" and assign the following function to its "click" event...
searchVal = document.getElementById("searchFor").value;
searchTyp = document.getElementById("searchType").value;
$.get('SiteSearchServlet', {searchFor: searchVal, searchType: searchTyp}, function(responseJson) { // Execute Ajax GET request on URL of "someservlet" and execute the following function with Ajax response JSON...
...
我尝试过忽略字符集,在ajaxsetup中仅使用cache=false - 没有帮助。单击 findSites 按钮时,不会执行 $.get ajax 调用。
谁能告诉我让 jQuery ajax GET 在 IE 上工作的秘诀吗?
I'm using jQuery 1.7.1 in a web app running on WebLogic 10.3.2. I do ajax GETs to the server. This all works fine in FF and Chrome, but nothing happens for the ajax events in IE 8. It's as if the doc ready didn't set them up at all.
Here's some of the js:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="css/messaging.css" />
<link rel="stylesheet" type="text/css" href="css/jquery-ui-1.8.17.custom.css" />
<link rel="stylesheet" type="text/css" href="css/ui.dynatree.css" />
<link rel="stylesheet" type="text/css" href="css/jquery.cluetip.css" />
<link rel="stylesheet" type="text/css" href="css/jquery-ui-timepicker-addon.css" />
<script type="text/javascript" src="js/jquery-1.7.1.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript" src="js/jquery.dynatree.js"></script>
<script type="text/javascript" src="js/jquery.cookies.2.2.0.js"></script>
<script type="text/javascript" src="js/jquery.cluetip.js"></script>
<script type="text/javascript" src="js/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="js/jquery-ui-sliderAccess.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$.ajaxSetup ({
cache: false,
xhrFields: {
withCredentials: true
},
crossDomain: true
});
...
$('#findSites').click(function() { // Locate HTML DOM element with ID "somebutton" and assign the following function to its "click" event...
searchVal = document.getElementById("searchFor").value;
searchTyp = document.getElementById("searchType").value;
$.get('SiteSearchServlet', {searchFor: searchVal, searchType: searchTyp}, function(responseJson) { // Execute Ajax GET request on URL of "someservlet" and execute the following function with Ajax response JSON...
...
I've tried leaving off the charset, using only cache=false in ajaxsetup - didn't help. The $.get ajax call doesn't execute when the findSites button is clicked.
Can anyone tell me the secret to getting jQuery ajax GETs to work on IE?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用 $.ajax 而不是 $.get,这样您就可以添加错误回调并查看 ajax 调用失败的原因。
http://net. tutsplus.com/tutorials/javascript-ajax/5-ways-to-make-ajax-calls-with-jquery/
(请参阅最后的“最后...”部分)
Try using $.ajax instead of $.get, that way you can add an error callback and see why the ajax call is failing.
http://net.tutsplus.com/tutorials/javascript-ajax/5-ways-to-make-ajax-calls-with-jquery/
(see the Finally... section at the end)