So my js file used to work great:
function checkLoggedIn() {
new Request.JSON({
url: 'http://localhost/site/ajax/auth.php',
onSuccess: function(data) {
// Do some stuff
}
}).send('action=check');
}
Then I decided to serve my page to the rest of the world, so I changed the code thusly:
function checkLoggedIn() {
new Request.JSON({
url: '<?=SOME_URL=>ajax/auth.php',
onSuccess: function(data) {
// Do some stuff
}
}).send('action=check');
}
Where in PHP, I've defined SOME_URL to point to the web server. I tried to test the site on the same machine (the web server), but imagine my surprise when it wouldn't work! The request just failed, although I have no idea how to check what error message there is. My js console is empty.
What's weir开发者_运维技巧d is if I replace the URL with a relative path, it works fine.
I tried accessing the web server on another computer, with the second code snippet, and it works great. Is the js parser on the server's browser (firefox) not liking the request pointing to itself? Why does it prefer "http://localhost/" over the FQDN?
Thanks!
Edit: For those wondering what the source shows:
function checkLoggedIn() {
new Request.JSON({
url: 'http://www.example.com/application/ajax/auth.php',
onSuccess: function(data) {
// Do some stuff
}
}).send('action=check');
}
The machine itself is example.com, defined as such on the machine and through apache confs.
What happens when you use /ajax/auth.php instead of 'http://www.example.com/application/ajax/auth.php'? This should work if they are on the same domain
精彩评论