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.
$.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
Post a Comment