javascript - 'this.response' is not printing in the console -


    function callotherdomain() {          var invocation = new xmlhttprequest();         var username = "usr";         var password = "pass";         var url = 'https://someurl';           invocation.open('get', url, true, username,password);           console.log(this.responsetext);                                         invocation.send();     } 

i not able response working code above

well first of all, responsetext response xmlhttprequest, should naturally member of invocation , not this.

secondly, since it's response of request, there won't before there have been actual response received. if request synchronous after send call. unfortunately asynchronous request, means have create response handler (using onreadystatechange property) , print response when response have been received.

i suggest follow link on onreadystatechange property, contains simple example on how handle async requests, doing want.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -