Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
-4
rated 0 times [  2] [ 6]  / answers: 1 / hits: 69779  / 15 Years ago, tue, march 2, 2010, 12:00:00

I'm having a hard time getting my AJAX requests to work on a staging server. It all worked fine on my development machine, but as soon as I uploaded it, all my AJAX requests stopped working. I found out that, if I change the relative urls (eg. index.php) to absolute urls (http://example.com/index.php) the requests work again, but I do not understand why.



Example request:



jQuery.post('index.php', {id: 1234, action: 1, step: 1}, function(data) { /* something */ });


This does not work, I does not even show up in the firebug console. The success handler is called though, which is very confusing.



This works just fine:



jQuery.post('http://example.com/index.php', {id: 1234, action: 1, step: 1}, function(data) { /* something */ });


Can anybody explain why AJAX requests behave in this way? x_X


More From » php

 Answers
10

Try adding a / before index.php in your first example to force it to look from root. Double check to make sure your directory-structures are exactly the same with regards to where index.php is.


[#97447] Friday, February 26, 2010, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jimmieo

Total Points: 515
Total Questions: 102
Total Answers: 110

Location: Kazakhstan
Member since Mon, Sep 26, 2022
2 Years ago
;