bottles beach
bottles beach

Reputation: 33

includes the jquery library in js of a chrome extension

I'm trying to run this ajax work:

    $ (document).ready(function() {
 $.ajax({
    url: 'sendvalue.php',
    type: 'POST',
    dataType:'json', 
    data: ({cookievalue: cookie.value}),
    success: function(data) {
       console.log(data);
    }
  });
});

But, rightfully so, since I have not put in the inclusion of the jquery ajax library (I cannot include because the script is in a js file and not in the index), I get this error:

index.html:1 Error handling response: ReferenceError: $ is not defined at chrome-extension://ebekofgaihoolgeccoalidkchcofecbd/main.js:9:4

I tried to auto-include the library but I get another error:

main.js:3 Refused to load the script 'https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js' because it violates the following Content Security Policy directive: "script-src 'self' blob: filesystem:". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

How can I solve?

Upvotes: 0

Views: 160

Answers (1)

MK Developer
MK Developer

Reputation: 36

Please Remove JS code from your main index file and add new js file and paste code there. All js and css files included in your index file And use functionality I think is work.

Upvotes: 0

Related Questions