Answer the question
In order to leave comments, you need to log in
Why is ajax request not working in google chrome extension?
Hello, I want to send information from the browser to my site for statistics through the google chrome extension, but the ajax request does not work
chrome.cookies.getAll({domain: "youtube.com"}, function(cookies) {
console.log('Callback for cookies came in fine.');
console.log('cookies.length=' + cookies.length);
for(var i=0; i<cookies.length;i++) {
console.log('cookie=' + cookies[i].name);
console.log('value=' + cookies[i].value);
$.ajax({
url: 'http://example.com/ajax-simple.json',
method: 'POST',
data: {message: cookies[i].value },
dataType: 'json'
});
}
});
Callback for cookies came in fine.
manager.js:3 cookies.length=4
manager.js:5 cookie=_ga
manager.js:6 value=GA1.2.1369799817.1497630654
manager.html:1 Error in response to cookies.getAll: ReferenceError: $ is not defined
at Object.callback (chrome-extension://iabhombknhnijfkeicjllkhlmoeciakp/manager.js:7:4)
at chrome-extension://iabhombknhnijfkeicjllkhlmoeciakp/manager.js:1:17
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question