Hey, Can AJAX retrieve the output from a URL and store the output of that url in a javascript var? The code I have is: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script><script type="text/javascript" src="js/jquery-ui-1.7.2.custom.min.js"></script><script type="text/javascript" src="js/si.files.min.js"></script><script type="text/javascript" src="js/json2.min.js"></script><script type="text/javascript" src="js/functions.js"></script><script type="text/javascript" src="js/jquery.cookie.js"></script><script type="text/javascript" src="js/jquery.blockUI.js"></script><script type="text/javascript" src="js/jquery.tools.min.js"></script><script type="text/javascript" src="js/flowplayer-3.1.2.min.js"></script><script type="text/javascript" src="js/jquery.hoverbox.min.js"></script><script type="text/javascript" src="js/global.js"></script><script <script src="/js/peel/AC_OETags.js" language="javascript"></script> <script src="/js/peel/pageear.js" type="text/javascript"></script><script type="text/javascript"> $.get("http://www.url.com/test.php", function(data){ alert(data) } ); </script> </head> <body> </body> </html> Code (markup): The test.php page says "hello". But when I load my page it does not show me an alert with that. Any idea what I am doing wrong? Thanks
AJAX requests can get data only from the same domain where the page you call script from is located. Except for JSON requests.
In the 1990s, most sites are based on full HTML pages, where any user action required that the page is loaded from the server (or a new page loads). This process is not effective, as evidenced by the experience of the user (the entire contents, then it disappears, etc.). Every time a page is reloaded due to a partial change, all content sent again instead of just the changed data. This may put additional pressure on the server and the excessive use of bandwidth.