javascript - $.getJSON 不工作

标签 javascript jquery json google-chrome-extension

我正在尝试为我的学校创建一个非常简单的 Chrome 扩展。我相当确定根本问题是 chrome 默认情况下不允许 XHR 请求,但同时期望填充 #results div ( here is the code )。我读过有关 jSONP 等某些内容的内容,但话又说回来,我不太确定是什么原因造成的。我将不胜感激任何帮助!谢谢!

最佳答案

要让 Chrome 扩展破坏跨源策略,您需要通过权限条目将域添加到 list 文件中:

"permissions": [
  "tabs",
  "bookmarks",
  "http://slu.edu/",
  "http://*.google.com/",
  "unlimitedStorage"
],

来源:http://code.google.com/chrome/extensions/manifest.html#permissions

关于javascript - $.getJSON 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6170339/

相关文章:

javascript - 什么时候需要在 TypeScript 中声明返回函数类型?

javascript - 将鼠标悬停在元素上 onclick

jquery - 如何使用 jquery 数据表在表上添加 div?

'src' 图像 URL 的 jQuery 嵌套选择器

c# - MVC.net 核心 : response type always json not xml with ICollection

javascript - 使用 Promise 将 Ember JS 转换为 Ember Data

javascript - 难以尝试在选择器的迷你对象中使用 .find() 和 .children

javascript - jQuery:模板化数据

javascript - 当我在 jQuery 中执行 AJAX 调用时出现 JSON 错误

java - 在java中将普通字符串转换为JSON