javascript - What does the Json onLoad do and how can i return something via the call? -
function jsoncall() { jsonclient.setrequestheader("content-type", "application/json"); jsonclient.send(data); jsonclient.onload = function() { someotherfunction(this.responsetext); } } // function in someother class. var object = { someotherfunction: function() { return data; } } - what jsoncall function return?
- can can return value onload call of json object?
i want logic in other class , return value via jsoncall function
looks odd me. jsonclient object supposed xhr object here. however, xhr object offers onreadystatechange event handle complete transfer checking readystate attribute.
the exception xdomainrequest object internet explorer. object indeed has .onload property. right now, jsoncall() methods returns undefined. need add callback method execute. like
function jsoncall( someotherfunction ) { jsonclient.setrequestheader("content-type", "application/json"); jsonclient.send(data); jsonclient.onload = function() { someotherfunction(this.responsetext); } } and call like
jsoncall( object.someotherfunction ); where hope object example word here.
Comments
Post a Comment