JavaScript
chrome-extension

chromeエクステンションでjsonpを読み込みメモ

More than 1 year has passed since last update.

jsonpが利用できるのに読み込んでくれない
because it violates the following Content Security Policy directive: "script-src 'self' blob: filesystem: chrome-extension-resource:".
コンソールにこんなエラーがでるとき

js側

$.ajax({
  type: 'GET',
  url: 'http://localhost:4000/jsonのパス',
  dataType: 'jsonp',
  jsonp: 'callback'
})
.done(function(data){
  console.log("成功");
})
.fail(function(data){
  console.log("エラー");
});

manifest.jsonにいかを追記

"content_security_policy":"script-src 'self' http://localhost:4000; object-src 'self'",

参考

http://noumenon-th.net/programming/2016/03/24/jsonp_jquery/
https://stackoverflow.com/questions/36622181/how-to-fix-chrome-extension-inline-javascript-invocation-error