Jump to content

Will this ever work ?


d.shankar

Recommended Posts

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 ?

Link to comment
https://forums.phpfreaks.com/topic/126406-will-this-ever-work/
Share on other sites

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/126406-will-this-ever-work/#findComment-655797
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.