0

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"></script>
      <script type="text/javascript" src="http://cdn.jquerytools.org/1.1.2/jquery.tools.min.js"></script>
      <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.

Tylo
  • 726
  • 1
  • 7
  • 15
  • 1
    Have you tried monitoring the request pipeline with Firebug, or checking the request logs on the server to see if the request is actually sent, and if so, what is the server's response? – Rex M Oct 21 '09 at 04:13
  • I'm fairly new to jQuery, and trying to find out how to decipher the information in Firebug isn't coming easy to me. What exactly am I looking for in this myriad of variables? – Tylo Oct 21 '09 at 04:22
  • Because you mentioned "displays the change" then in addition the 405 err, possibly there's a caching issue in play also. This might be something to be aware of as you debug. – John K Jan 23 '10 at 06:03

2 Answers2

0

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 omuraliev
  • 171,706
  • 64
  • 370
  • 423
  • 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 Oct 21 '09 at 04:15
  • What does the ajax call return? – meder omuraliev Oct 21 '09 at 04:17
  • 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 Oct 21 '09 at 04:22
  • 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 Oct 21 '09 at 04:25
  • what is `url` and where does the actual page live in? – meder omuraliev Oct 21 '09 at 04:32
  • 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 Oct 21 '09 at 04:37
  • so your local webserver supports POST requests to test.html, yet it doesn't on the production server? – meder omuraliev Oct 21 '09 at 04:38
  • 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 Oct 21 '09 at 04:40
0

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
  • 42,243
  • 5
  • 64
  • 107