Jump to content

in case of an otherserver/page.html with ajax get


lse123
 Share

Recommended Posts

At http://www.w3schools.com/jquery/jquery_ajax.aspthere are some jQuery ajax examples, when want to get other server url's html code page (and preferred only div text with id=("article_main")), well below code failed, is only for native urls? what to use in this case or in case of an otherserver/page.html? txt1=xmlhttp.responseText;txt=txt1.getElementsById("article_main");

<html><head><script type="text/javascript" src="jquery.js"></script><script type="text/javascript">$(document).ready(function(){  $("button").click(function(){  alert("pressed");    $("#gl").load("http://www.yyyy.com/cyprus-property/taxes-fees.html");    });  });//});</script></head><body><p>Artists</p><div id="gl"></div><button>Get html info</button></body></html>

Link to comment
Share on other sites

AJAX, originally, only works for the same domain. I don't know yet if browsers have extended the permissions beyond that. If you need to get content from another domain you will need to get a server-side language to load the content for you. PHP, for example, has the cURL library.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...