Skip to content

Instantly share code, notes, and snippets.

@yamaryu0508
Last active November 14, 2017 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yamaryu0508/68bb9f6c8e7772c24d1bfb08ef954aa8 to your computer and use it in GitHub Desktop.
Save yamaryu0508/68bb9f6c8e7772c24d1bfb08ef954aa8 to your computer and use it in GitHub Desktop.
非同期XHRによるレコード取得APIのリクエスト
var url = kintone.api.url('/k/v1/records', true) + '?app=' + kintone.app.getId();
var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.onload = function () {
if (xhr.status === 200) {
// success
console.log(JSON.parse(xhr.responseText));
} else {
// error
console.log(JSON.parse(xhr.responseText));
}
};
xhr.onerror = function (err) {
// error
console.log(err);
};
xhr.onreadystatechange = function () {
// show headers
if (this.readyState === this.HEADERS_RECEIVED) {
console.log(xhr.getAllResponseHeaders());
}
};
xhr.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment