Hi I am developing a chrome extension. Now my extension can get and send request with user on click . But i want when user navigates any site extension on background will send a POST request each time user loads a new page on browser. I have tried to look for any examples or tutorials but ended up nothing specific. Can someone refer any link or working example how chrome listens when user loads a new page and send POST request ?
1 Answer
In your background page:
chrome.tabs.onUpdated.addListener( function(tabId, changeInfo, tab) {
if(changeInfo.status == "loading"){
var request = new XMLHttpRequest();
request.open("POST", "http://www.oh-hi-denny.com/", true);
request.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
request.send(JSON.stringify({denny: 1, mark: 1, johnny: 0}));
}
});
-
hi . I tried that. but i am continiously getting internal server error 500.– user12Commented Sep 17, 2015 at 14:00
-
1That can have a number of reasons, none of which is the code above. You have to look for the error in the server or in your request. Can you reproduce this error with postman?– cviejoCommented Sep 17, 2015 at 14:14
-
2Where have you uploaded it? You should probably post a different question about this.– cviejoCommented Sep 18, 2015 at 8:22