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’
mypage.php
<span style="color:#008000;"><html> <head> <script type="text/javascript" src="prototype.js"></script> </head> <body> <script> var url = "ajax_req.php"; new Ajax.Request(url, {method: 'post',parameters: '', onSuccess: function(data){ document.getElementById('ajax_response').innerHTML = data.responseText; } }); </script> <div id="ajax_response"></div> </body> </html></span>
ajax_response.php
<span style="color:#008000;"><?php // you can request an xml file, parse the xml file and print the elements $url = "http://www.google.com/search?hl=en&q=javascript&btnG=Search"; $string = file_get_contents($url); // you can apply regular expression here for parsing echo $string ?></span>
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.