views:

243

answers:

2

EDIT: I have discovered that this is a 405 error. So there is something going on with the webserver and handling POST methods.

I am having a strange occurrence. I have identical javascript code on both my test environment and production environment.

The test environment functions, and the production does not. Here is my identical code.

<html>
    <head>
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt;
      <script type="text/javascript" src="http://cdn.jquerytools.org/1.1.2/jquery.tools.min.js"&gt;&lt;/script&gt;
      <script type="text/javascript" src="./js/jquery.scrollTo-min.js"></script>
    </head>
    <body>
      <div class="content" id="content"> 
        <a id="changeText" href="test.html">Change</a>
      </div>

      <script>
         $(document).ready(function() {

            $("#changeText").live('click', function(){

                var url = $(this).attr("href");

                $("#content").load(url, {var1:Math.random()*99999},function(){

                     alert(url + " loaded");
                });

                $.scrollTo("0%", 400);

           return false;
            });
        });
     </script>
    </body>
</html>

Both environments report that

alert(url + " loaded");

is happening. But only my test environment actually displays the change.

The production webserver has "test.html" available in the correct location.

A: 

Are you sure the scrollTo script is being included on the production server ( or am I misinterpreting what you mean by change ) ? Perhaps try a root relative path instead of './js'? I would check Firebug's script tab to ensure it is being included.

meder
I am positive, because the scrollTo is functioning. The only bit that is not functioning is the div contents changing due to the AJAX call.
Tylo
What does the ajax call return?
meder
I'm not really sure how to catch what it is returning. Do I just set it equal to a variable and then print that to my console?
Tylo
Ah, I see what is going on now. I am getting a 405 method not allowed error. I'm not certain how to handle that, however.
Tylo
what is `url` and where does the actual page live in?
meder
url is the href value of the link. so in this case, it would be test.html. test.html would be in the same folder as the page linking to it.
Tylo
so your local webserver supports POST requests to test.html, yet it doesn't on the production server?
meder
That appears to be the case. To be honest, I didn't know that much about my production server. I've never had to deal with this problem until now.
Tylo
A: 

405 errors mean that the URL you're sending to isn't expecting you to send the data in that manner. For example, if you're sending a POST request to a URL that's only designed to handle a GET request, you'll get this error.

My guess is whatever server you're running on is set up to not allow POST data to be sent to a page with a .html extension, causing the error you're seeing. Try changing the extension to a .php, .aspx, etc, and see if that helps.

jvenema