javascript - How to get the response of XMLHttpRequest? -


I would like to use XMLHttpRequest to load the content of a remote URL and the HTML of the accessed site is a JS Stored in the variable.

Say if I want to load and warn (HTML), how do I do this?

You can do this when XMLHttpRequest.readyState XMLHttpRequest .DONE . .

Here is an example (not compatible with IE 6/7).

  var xhr = new XMLHttpRequest (); Xhr.onreadystatechange = function () {if (xhr.readyState == XMLHttpRequest.DONE) {Warning (xhr.responseText); }} Xhr.open ('GET', 'http://example.com', is true); Xhr.send (zero);  

With IE 6/7 not only for better crossbrother compatibility, but also to cover some browser-specific memory leaks or bugs, and with the firing of Ajay related requests For clarity, you can use.

  $ .get ('http://example.com', function (response text) {warning (feedback text);});  

Note that you will have to keep in mind while not running on a local host. You may want to consider creating a proxy script on your domain.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -