I have a very simple call to some server, using jQuery to make my life easier.
popup.js
var url = "https://svcs.ebay.com/services/search/FindingService/v1";
url += "?OPERATION-NAME=findItemsByKeywords";
url += "&SERVICE-VERSION=1.0.0";
url += "&SECURITY-APPNAME=LuisDavi-son19975-PRD-27f3a1ec0-de5a37b4";
url += "&GLOBAL-ID=EBAY-US";
url += "&RESPONSE-DATA-FORMAT=JSONP";
url += "&REST-PAYLOAD";
url += "&keywords=4%20Apple%20iPhone%20Model%20A1332%20FOR%20PARTS%20ONLY";
var EbayPriceS = 0;
var SeRiCount = 0;
$(document).ready(function() {
$.ajax({
type: "POST",
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
dataType: 'jsonp',
url: url,
crossDomain : true,
xhrFields: {
withCredentials: true
}
})
.done(function( root ) {
SeRiCount = root.findItemsByKeywordsResponse[0].searchResult[0]["@count"];
alert(SeRiCount);
})
.fail( function(xhr, textStatus, errorThrown) {
alert(xhr.responseText);
alert(textStatus);
});
});
Basically, it boils down to returning me some data from eBay, and the thing is, that this works if I use this code in some local HTML file. (I have an alert that shows SeRiCount
value)
However, if I try and run this same thing from a Chrome extension, I don't get the same thing. I get an error response. And my question would be, why?
manifest.json
{
"manifest_version": 2,
"name": "Bid Support Extension",
"description": "This extension supports the adoption of bid resolution when buy the product.",
"version": "1.0",
"permissions": [
"https://svcs.ebay.com/*"
],
"browser_action": {
"default_icon": "icon.png"
},
"content_scripts": [
{
"matches": ["https://www.shopgoodwill.com/*", "https://www.ebay.com/sch/i.html?_from=*"],
"js": ["jquery.min.js", "popup.js"]
}
]
}
As you can see, nothing funky is going around in the manifest.json
file either, and when I get the error log, it says this:
Am I missing something? Should I include some stuff in the manifest.json
or I just can't make calls from Chrome extension to this server?