Define Javascript Variable With Contents of URL -


I've got a GeoCoder website that will give me some data in some JavaScript code as a variable. The website only returns content: 38.393314, -122.83666, Sebastopol, CA, 95472. I need to pull this information from the website and put it in the string.

abc = "38.393314, -122.83666, Sebastopol, CA, 95472"

How can I do this?

You can use it:

  var req = new XMLHttpRequest (); // Create an AJAX object req.open ('GET', 'http: //geocoder.us/service/csv/geocode? Zip = 95472', true); // location and method req.send (); // send req.onreadystatechange = function () {// when it is ready (this.readyState === 4) {// ... which is code 4 console.log (this.responseText); // Then you have the response text}}   

This only works when the request is from the same domain, though (for security purposes). If you want to work it on any domain, you will need to use a proxy.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -