由于错误的MIME类型,Chrome拒绝执行Ajax脚本。

SmiPaul Nelligan提出了一个问题:Chrome refuses to execute an AJAX script due to wrong MIME type,或许与您遇到的问题类似。

回答者Quentin给出了该问题的处理方式:

By adding a callback argument, you are telling jQuery that you want to make a request for JSONP using a script element instead of a request for JSON using XMLHttpRequest.

JSONP is not JSON. It is a JavaScript program.

Change your server so it outputs the right MIME type for JSONP which is application/javascript.

(While you are at it, stop telling jQuery that you are expecting JSON as that is contradictory: dataType: 'jsonp').

希望本文对你有帮助,欢迎支持JavaScript中文网

原文链接:stackoverflow.com

上一篇:custom-guider
下一篇:如何使用jQuery将元素滚动到视图中?

公众号

欢迎 JavaScript 爱好者