2012-10-20 32 views
0

这里是我的jQuery AJAX方法,它只适用于Ie,但不适用于Chrome或Firefox。我的代码是Jquery AJAX方法只适用于IE浏览器

<!DOCTYPE html> 
    <html> 
<head> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js?ver=1.3.2">  
</script> 
<script> 
$(document).ready(function() { 
    $("button").click(function() { 
     $.ajax({ 
      url: "http://50.116.19.49/rest/user.json", 
      success: function(result) { 
       $("div").text(result); 
      } 
     }); 
    }); 
}); 
</script> 
</head> 
<body> 

<button>Get JSON data</button> 
<div></div> 

</body> 
</html> 
+0

服务器文件是否在相同的IP? – Sutha

+0

您是否尝试过更新版本的jQuery?任何控制台错误? – Sparky

+0

这两个文件都在不同的ips –

回答

0

您可以jquery.xdomainajax.js

Remeber这样做是为了明确type GET它。

$("button").click(function() { 
    jQuery.ajax({ 
     url: "http://50.116.19.49/rest/user.json", 
     type: 'GET', 
     success: function(result) { 
      $("div").text(result.responseText); 
     } 
    }); 
});​ 

这是Fiddle

+0

您的代码可以在小提琴上完美工作,但是当我将其复制到本地机器时,它将停止工作。任何评论 –

+0

你忘记了包含xdomainajax.js –

相关问题