javascript - How to call outside page using ajax/jquery instead of using iframe? -
i need call page example http://www.google.com specific div. had done using ajax...
$.ajax({      url : 'http://www.google.com',      success : function (data)      {          $('#my-div').html(data);      } }); but not work....is there better ways instead of using <iframe> ?
your code not work due same-origin policy (if ajax code on www.mysite.com, can send ajax requests other files on www.mysite.com).
here 2 common solutions:
1) if can write server side code, can ajax own domain, scrape www.google.com using curl , return response.
2) ajax can use jsonp 1 condition server (www.google.com in case) configured jsonp responses. checkout jquery doc how go jsonp.
Comments
Post a Comment