, ,

When we trying to create the variable assignment, we make an ajax request and pass the URL to get the response and create the variable assignment. Ajax requests are bound to same domain as the webpage. If we are on http://www.abcd.com we’ll get an error if we try to make an Ajax request to http://www.someotherdomain.com.

I’ve faced the same problem but I’ve done it very simple way.

I’ve used the prototype js for ajax calling, and two pages ‘mypage.php’, ajax_response.php’


<span style="color:#008000;">&lt;html&gt;
&lt;script type="text/javascript" src="prototype.js"&gt;&lt;/script&gt;
var url = "ajax_req.php";
new Ajax.Request(url, {method: 'post',parameters: '',
onSuccess: function(data){
document.getElementById('ajax_response').innerHTML = data.responseText;
&lt;div id="ajax_response"&gt;&lt;/div&gt;


<span style="color:#008000;">&lt;?php
// you can request an xml file, parse the xml file and print the elements
$url = "http://www.google.com/search?hl=en&amp;q=javascript&amp;btnG=Search";
$string = file_get_contents($url);
// you can apply regular expression here for parsing
echo $string

When ‘mypage.php’ run automatically called the an ajax request then it called the ajax_response.php page, the file_get_contents(‘url’) function will return any external web page. we can do here anything whaterver we want.

I’ve already used it and worked very well.