HTTP 405错误? Post方法适用于一个页面但不适用于另一个页面(AJAX,Jquery,$ .post)

时间:2012-08-13 02:39:29

标签: php jquery html ajax html5

我对自己遇到的麻烦感到困惑。

我有一个在IIS中托管的网站(在测试阶段,所以一切都通过localhost)

IIS 7.5

在我的主页(用HTML编写)中,我使用PHP脚本($ .post方法)与WCF服务进行通信以验证用户身份(完美运行)。

我还有一个注册页面,它使用不同的PHP脚本与同一个WCF Web服务进行通信。但是,当我尝试使用$ .post方法时,我收到HTTP 405错误。什么让我感到害怕的是,我不明白它是如何在一个页面上完美的,并在另一个页面上抱怨?

我在我的主页上调用我的$ .post方法,如下所示:

 $.post('authenticate.php', $("#frmLogin").serialize(), function(data) {
                        //do stuff  
                }); 

没问题。

在调用不同php脚本的不同html页面上的相同方法:

 $.post('registration.php', $("#frmRegister").serialize(), function(data) {
                            //do stuff
                    });

我收到HTTP 405错误 - 不允许使用方法。

可能是罪魁祸首?我已经将.php添加到IIS处理程序映射中,我允许所有动词但同样的问题。我已经尝试将我的WCF方法更改为“POST”而不是“GET”(我的身份验证使用的是GET,但仍有问题。)

更新

这是registration.php文件的php代码

         <?php


    $UserName = $_POST['UserName'];
    $PassWord = $_POST['PassWord'];
    $Email = $_POST['Email'];


    $wcfClient = new SoapClient('http://localhost/AYAFYAuthenticate/AuthenticationService.svc?wsdl');

    $args = array('uname' => $UserName,'pword' => $PassWord,'email' => $Email);

    $response = $wcfClient->CreateUser($args);

    echo $response->CreateUserResult;
    ?>

这是有效的authentication.php文件:

         <?php


    $UserName = $_POST['UserName'];
    $PassWord = $_POST['PassWord'];


    $wcfClient = new SoapClient('http://localhost/AYAFYAuthenticate/AuthenticationService.svc?wsdl');

    $args = array('uname' => $UserName,'pword' => $PassWord);

    $response = $wcfClient->Authenticate($args);

    echo $response->AuthenticateResult;
    ?>

谢谢,

1 个答案:

答案 0 :(得分:0)

http://www.checkupdown.com/status/E405.html显示了如何修复405错误。从阅读那里,我假设它是服务器端的东西。如果你发布php会有帮助

相关问题