It look like $.ajax
always trigger error event function
but GM_xmlhttpRequest
can retrieve mistype data,
so I try looking for dataType: "jsonp"
in GM_xmlhttpRequest
and I got that jsonp header content-type is "application/javascript"
OR "application/json"
and the first one work well.
my new code for retrieve data look like this
GM_xmlhttpRequest({
method: "GET",
url: "http://api.openkeyval.org/test-key-data?nocache=" + new Date(),
headers: {
"Content-Type": "application/javascript"
},
onload: function(response) {
console.log(response.responseText);
}
});
and retrieve data using $.ajax
even it always trigger error event function but it still send data.
I try both content-type on GM_xmlhttpRequest
and still not work.
my code to store data look like this
$.ajax({ /* send data */
url: "http://api.openkeyval.org/store/",
data: "test-key-data=" + JSON.stringify(myVarObject),
dataType: "jsonp"
});