Friday, November 27, 2009

Re: [jQuery] PHP jQuery on different port

The port is part of the url (80 is implicit for http), so you've got to explicitly set it to access port 8080, like this :
http://whatever.yoursite.is:8080/any_script.php?any_other_argument=some_value

Michel Belleville

2009/11/26 Darjana <darjana@gmail.com>
Hello,

This user.php on port 80
$callback = $_GET["callback"];
$user = $_GET["username"];

if($user == "lazy") {
 $response = array("message" => "SUCESS");
} else {
 $response = array("message" => "FAIL");
}

echo $callback . "(". json_encode($response) . ");";

This is index.html on port 8080

$.getJSON("user.php?callback=?", { username: "lazy"}, function(json){
 alert("JSON Data: " + json.message); // SUCCESS
});

This is working if both files on same port, however, it doesn't when
its not on same port

Any workaround for this to work?

No comments: