Ajax not working with chrome extension with v2 manifest

I'm trying to play around with the basic chrome extension, which looks something like this.

chrome.omnibox.onInputChanged.addListener(function(text, suggest){
       var baseUrl = "http://sample.com";
       var finalResult = [];
              $.ajax({
                     url : baseUrl,
                     dataType : "jsonp",
                     success: function(result) {
                                     for (var i=0; i<result[1].legnth; i++){
                                          finalResult.push(
                                                 {content : result[1][i], description : result[1][i]}
                                          );
                                     }
                                     suggest(finalResult);
                              },
                     async: false
              });           
});

This works with manifest version 1, but when I change it to v2, I get the following error. I would be grateful for any help :)

Refused to download script 'http://sample.com' because it violates the following content security policy directive: "script -src 'self' chrome-extension-resource:".

+5
source share
1 answer

You should read about the content security policy.

complete the manifest file with

    "content_security_policy": "script-src 'self' http://sample.com; object-src 'self'",
+8
source

All Articles