jQuery AJAX URL路径问题

时间:2011-07-28 04:19:12

标签: php jquery

在jQuery AJAX网址中,如果我给http://172.121.0.1/filename.php,它就可以了。如果我给http://localhost/filename.php那么它就可以了。请帮帮我。

$.ajax({
          url: "http://172.22.0.155/login/login_check",
          type: "POST",
          data:$("#logins").serialize(),
          beforeSend: function(){
            $("#err").html("");
          },
          success: function($msg){
             if($msg=="yes"){
                document.location.href=urls+"main/";
             }else{
               $("#err").html("Please enter correct username and password");
               return false;
             }
          },error:function (msg){
           alert(msg);
          }
        });

2 个答案:

答案 0 :(得分:0)

主要是你的iis设置问题,而不是jquery ajax问题。在浏览器中尝试“http://172.121.0.1/filename.php”直接查看它是否有效。

答案 1 :(得分:0)

大多数系统将localhost定义为127.0.0.1

尝试使用该IP并查看它是否有效。

此外,如果您使用的是发送此呼叫的服务器,则不需要域/ IP。

如果您遇到的服务器不同于CORS问题。