Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery ajax在IE中不起作用_Jquery_Ajax_Internet Explorer - Fatal编程技术网

jQuery ajax在IE中不起作用

jQuery ajax在IE中不起作用,jquery,ajax,internet-explorer,Jquery,Ajax,Internet Explorer,我在WebLogic 10.3.2上运行的web应用程序中使用jQuery 1.7.1。我不想让ajax访问服务器。这一切在FF和Chrome中都可以正常工作,但在IE8中ajax事件不会发生任何变化。就好像准备好的医生根本就没有设置好 以下是一些js: <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE ht

我在WebLogic 10.3.2上运行的web应用程序中使用jQuery 1.7.1。我不想让ajax访问服务器。这一切在FF和Chrome中都可以正常工作,但在IE8中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...
...

$(文档).ready(函数(){
$.ajaxSetup({
cache:false,
xhrFields:{
证书:正确
},
跨域:对
});
...
$('#findsite')。单击(function(){//Locate ID为“somebutton”的HTML DOM元素,并将以下函数分配给其“click”事件。。。
searchVal=document.getElementById(“searchFor”).value;
searchTyp=document.getElementById(“searchType”).value;
$.get('SiteSearchServlet',{searchFor:searchVal,searchType:searchTyp},函数(responseJson){//对“someservlet”的URL执行Ajax get请求,并使用Ajax响应JSON执行以下函数。。。
...
我已经尝试取消字符集,在ajaxsetup中仅使用cache=false-没有帮助。单击findSites按钮时,$.get ajax调用不会执行


有谁能告诉我让jQuery ajax开始在IE上工作的秘诀吗?

尝试使用$.ajax而不是$.get,这样可以添加一个错误回调,并查看ajax调用失败的原因


(请参阅结尾的最后…部分)

如果您将
console.log()
alert()
放在
$.get()
执行的位置,那么它会执行吗?谢谢-我添加了.error(函数(jqXHR,textStatus,errorwhold){alert(“error:+errorwhold);})”到我的$。取而代之的是(事实上是一样的)并得到一个“无传输”错误。谷歌搜索说这与跨域问题有关。然后我添加了这一行以强制IE允许:“jQuery.support.cors=true;//强制跨站点脚本”。这让ajax调用成功了!希望这对其他人有帮助。很高兴它有所帮助。请确保在ajax调用后将jQuery.support.cors设置为false,以防止出现不必要或意外的XSS。