开发者

jQuery $.load() functioning on personal webserver, but not production webserver

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开发者_如何学Go>
    </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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜