我在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...
...
我试过离开charset,在ajaxsetup中只使用cache = false - 没有帮助。单击findSites按钮时,$ .get ajax调用不会执行。
有人能告诉我让jQuery ajax GET在IE上工作的秘诀吗?
答案 0 :(得分:2)
尝试使用$ .ajax而不是$ .get,这样就可以添加错误回调并查看ajax调用失败的原因。
http://net.tutsplus.com/tutorials/javascript-ajax/5-ways-to-make-ajax-calls-with-jquery/ (参见最后的......最后一节)