Last active
November 14, 2017 09:54
-
-
Save yamaryu0508/68bb9f6c8e7772c24d1bfb08ef954aa8 to your computer and use it in GitHub Desktop.
非同期XHRによるレコード取得APIのリクエスト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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