Avatar

Error using AJAX

Tyler Moore

I have updated my code to what is below and im now getting a different error: jquery.min.js:2 GET https://<domain>.kintone.com/k/v1/records.json?app=6&callback=jQuery34107591808757762462_1583879308454&_=1583879308455 net::ERR_ABORTED 520

 
varsettings = {
'cache':false,
'dataType':"jsonp",
"async":true,
"crossDomain":true,
"method":"GET",
"headers": {
"accept":"application/json",
"Access-Control-Allow-Origin":"*",
"X-Cybozu-API-Token":"token"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
Follow 3 followers
0

3 comments

Avatar
Sean Tachibana 0 votes
Hello Tyler,
 
I have checked the code and seems like its just a typo where is says:
 
 
'dataType':"jsonp",
 
it should be
 
'dataType':"json"
 
 
Hopefully that helps.
0
Comment actions Permalink
Avatar
Tyler Moore 0 votes

We tried this. However it came up with the following alarm. It’s a CORS alarm. This is what a application engineer told us to do to avoid said alarm.

 

Access to XMLHttpRequest at 'https://<domain>.kintone.com/k/v1/records.json?app=6' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

0
Comment actions Permalink
Avatar
Yuzo Arai 1 vote

Hello Tyler,

The error that you see is most likely caused by the cross-domain restriction. You should execute the API from the server side to avoid the error.
*Sorry couldn't find any helpful site for reference.

1
Comment actions Permalink