LoginSignup
31
27

More than 5 years have passed since last update.

javascriptでサーバーからJSON取得

Posted at
JSON.js
var xmlHttpRequest = new XMLHttpRequest();
xmlHttpRequest.onreadystatechange = function()
{
    if( this.readyState == 4 && this.status == 200 )
    {
        if( this.response )
        {
            console.log(this.response);
            // 読み込んだ後処理したい内容をかく

        }
    }
}

xmlHttpRequest.open( 'GET', 'ここにURL', true );
xmlHttpRequest.responseType = 'json';
xmlHttpRequest.send( null );
31
27
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
31
27