H
H
heatshot132018-04-13 09:37:50
JavaScript
heatshot13, 2018-04-13 09:37:50

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'
});
    }
  });

At the exit
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

1 answer(s)
V
Vitaly, 2018-04-13
@vshvydky

$ is not defined

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question