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;         }    } 
  1. what jsoncall function return?
  2. 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

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -