jQuery的AJAX不工作在IE9 [英] Jquery AJAX not working in IE9
问题描述
我在写一个Ajax的Web应用程序,但无论出于何种原因,当我执行针对在Internet Explorer 9(IE9)内部数据服务的GET这是行不通的。这同一个呼叫工作完全正常在Chrome,Firefox和Safari。我使用的是本地主机Web服务器(WAMP)进行开发,开发同一个网络数据业务我想击中。我使用jQuery 1.8.1(我已经回到了几个版本,但仍然可以看到这个问题)。我的code是这样的:
I am writing an ajax web application but for whatever reason when I perform a GET against an internal data service in Internet Explorer 9 (IE9) it does not work. This same call works perfectly fine in Chrome, Firefox and Safari. I am using a localhost web server (wamp) for development and developing on the same network as the data service I am trying to hit. I am using Jquery 1.8.1 (I have gone back a few versions but still see the problem). My code looks like this:
$(document).ready(function() {
var loginUrl = "http://omittedurl.com";
console.log(loginUrl);
$.ajax({
type : "GET",
url : loginUrl,
dataType : "json",
success : function(response) {
console.log("RESPONSE: " + response);
}
});
});
正如我说这code正常工作的Chrome和Firefox之前。在IE9中,当我看着网页调试还有日志中没有错误。它像IE9,纯粹是忽略了阿贾克斯块。我已经试过的东西:
As I stated before this code works fine on Chrome and Firefox. In IE9 when I look at the web debugger there are no errors in the logs. It is like IE9 is just complete ignoring the .ajax chunk. Things I have tried:
- 在打开的Ajax缓存关闭
- URL连接codeD我的要求网址
- 回到三旧版本的jQuery
- 手动从IE9 ping通我的网址(能得到回应)
任何想法??
推荐答案
看的喜欢它的一个问题。
Look's like its a problem with
的console.log()
IE浏览器没有控制台对象时,开发人员工具是无法打开..尝试通过注释你的console.log运行您code,然后重试。
IE has no console object when Developer tools is not open.. Try running your code by commenting your console.log and try again..
$(document).ready(function () {
var loginUrl = "http://omittedurl.com";
//console.log(loginUrl);
$.ajax({
type: "GET",
url: loginUrl,
dataType: "json",
success: function (response) {
// console.log("RESPONSE: " + response);
alert("RESPONSE: " + response)
}
});
});
如果你想使用控制台,您需要定义,首先,如果开发工具的不开放。
If you want to use console , you need to define that first if Developer tool's is not open..
if (typeof console === "undefined" || typeof console.log === "undefined") {
console = {};
这篇关于jQuery的AJAX不工作在IE9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!