Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.