简体   繁体   English

Chrome处于浏览器状态时,Internet Explorer不返回AJAX呼叫

[英]Internet Explorer not returning AJAX call while Chrome is

I'm testing an application in Google Chrome and Internet Explorer right now. 我现在正在Google Chrome和Internet Explorer中测试一个应用程序。 I have a an AJAX call to a PHP script that returns data from a database, which is then appended to a $('#div') element via JavaScript ... the code functions correctly in Chrome (which is why I don't think it's a code issue) (it takes a second or two to load) ... in IE, however, it's not working (the $('#div') element isn't loading the returned JSON data (like it does in Chrome, albeit it takes a second or two)) ... I've researched other threads and have tried to troubleshoot a potential timeout issue ... any ideas to help troubleshoot? 我有一个对PHP脚本的AJAX调用,该脚本从数据库返回数据,然后通过JavaScript将其附加到$('#div')元素...代码在Chrome中正常运行(这就是为什么我不这样做认为这是一个代码问题)(加载需要一两秒钟)...但是,在IE中,它不起作用($('#div')元素未加载返回的JSON数据(就像在Chrome浏览器,尽管要花一两秒钟的时间))...我已经研究了其他线程,并试图解决潜在的超时问题...有什么想法可以帮助解决问题?

Yes. 是。 JS tends to block code from running, whenever there is another JS error on the page. 每当页面上出现另一个JS错误时,JS都会阻止代码运行。 Check IE's equivalent of console.log, to make sure that you don't see any more JS errors either in your code or from some upstream script provider... like a 3rd party ad vendor. 检查IE的console.log版本,以确保您在代码中或在上游脚本提供者(例如第三方广告供应商)中都看不到任何JS错误。

Also, IE doesn't like certain things, which Chrome, Firefox, Safari & Opera will allow... like a trailing comma at the end of the JSON object, before the closing brace "}". 而且,IE不喜欢某些东西,Chrome,Firefox,Safari和Opera会允许...,就像JSON对象末尾的逗号(在右括号“}”之前)一样。 That will break in IE, but not in other browsers, which are more forgiving. 这将在IE中中断,但在其他更宽容的浏览器中不会中断。 Example: The comma after apples will break in IE. 示例:苹果后的逗号将在IE中中断。 So look for any trailing commas & remove them. 因此,请查找任何结尾的逗号并将其删除。

{
   "a": 123,
   "b": "Hello World",
   "c": "apples",
}

Try using Fiddler to inspect the network traffic, which goes over the wire from IE. 尝试使用Fiddler检查网络流量,该流量通过IE进行。 It's like Chrome's Network tab & it will show you if the Ajax request is being sent & if so, what's coming back from the Ajax call. 就像Chrome的“网络”标签一样,它会向您显示是否正在发送Ajax请求,如果发送,则会显示Ajax调用返回的内容。 You might find an error in that callback & additional clues, as to what's blocking IE from working. 您可能会在该回调和其他提示中发现错误,以了解导致IE无法正常运行的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM