jquery - Display json array from given url -


im new json , ask question after couple of days of searching without result. have url contain json array, know how display table prepered keys. e.g: username , password , email first table row , need fill data. im use jquery due lack of knowlage in ajax.

when don't alert here, request failed. why there .fail() method:

$.getjson( "test.js", { name: "john", time: "2pm" } ) .done(function( json ) {     console.log( "json data: " + json.users[3].name ); }) .fail(function( jqxhr, textstatus, error ) {     var err = textstatus + ', ' + error;     console.log( "request failed: " + err); }); 

take @ documentation.

when want retrieve json data post, cannot use $.getjson:

load json-encoded data server using http request.

try instead:

$.post( "justaurl") .done(function( data ) {     var json = json.parse(data);     alert( json.users[3].firstname ); }) .fail(function( jqxhr, textstatus, error ) {     var err = textstatus + ', ' + error;     alert( "request failed: " + err); }); 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -