d.shankar Posted September 30, 2008 Share Posted September 30, 2008 I dont know whether i am running over a crossdomain issue ?? My php code at localhost <?php ?> <html> <head> <script type="text/javascript"> var http = new XMLHttpRequest(); var url = "http://www.myremotedomain.com/example.php"; var params = "lorem=ipsum"; http.open("GET", url+"?"+params, true); http.onreadystatechange = function() {//Call a function when the state changes. if(http.readyState == 4 && http.status == 200) { alert(http.responseText); } } http.send(null); </script> </head> <body> </body> </html> <?php ?> My PHP code at remote host <?php echo "$_GET['lorem']"; ?> So when i run my code at localhost , i should get the alert "ipsum" but i am getting a blank page.. But This code works when i copy the remote php file to the same directory where the localphp file is and if i change the http://www.myremotedomain.com/example.php to example.php it works !! But i cant make this to work remotely... Any help ? Quote Link to comment https://forums.phpfreaks.com/topic/126406-will-this-ever-work/ Share on other sites More sharing options...
ratcateme Posted September 30, 2008 Share Posted September 30, 2008 a quick google lead me to this page http://code.google.com/p/cross-domain-ajax/ it semes ajax will fail if you try to query to a diffrent domain. Scott. Quote Link to comment https://forums.phpfreaks.com/topic/126406-will-this-ever-work/#findComment-653657 Share on other sites More sharing options...
redarrow Posted September 30, 2008 Share Posted September 30, 2008 correct....... no solution use php only........ Quote Link to comment https://forums.phpfreaks.com/topic/126406-will-this-ever-work/#findComment-653660 Share on other sites More sharing options...
d.shankar Posted September 30, 2008 Author Share Posted September 30, 2008 I thought so. Thank you for your time guys....... Quote Link to comment https://forums.phpfreaks.com/topic/126406-will-this-ever-work/#findComment-653667 Share on other sites More sharing options...
d.shankar Posted October 2, 2008 Author Share Posted October 2, 2008 Can this be achieved with JSON ?? Quote Link to comment https://forums.phpfreaks.com/topic/126406-will-this-ever-work/#findComment-655594 Share on other sites More sharing options...
RichardRotterdam Posted October 2, 2008 Share Posted October 2, 2008 why don't you use a local php file to read data from a remote server? Quote Link to comment https://forums.phpfreaks.com/topic/126406-will-this-ever-work/#findComment-655715 Share on other sites More sharing options...
d.shankar Posted October 2, 2008 Author Share Posted October 2, 2008 The above example is just a prototype.. I SHOULD have that file to be in the remote side. Quote Link to comment https://forums.phpfreaks.com/topic/126406-will-this-ever-work/#findComment-655730 Share on other sites More sharing options...
RichardRotterdam Posted October 2, 2008 Share Posted October 2, 2008 are you saying you cant use any php what so ever? if you could use a local php file the solutions have been discussed here http://www.phpfreaks.com/forums/index.php/topic,210317.0.html and http://www.phpfreaks.com/forums/index.php/topic,210317.0.html if you can't use any local file then yes it is a crossdomain security thing. and json wouldn't work either only difference between ajax and json is that you are sending javascript objects instead of plain text/html Quote Link to comment https://forums.phpfreaks.com/topic/126406-will-this-ever-work/#findComment-655797 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.