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


HTTP 405 Error? Post method works on one page but not the other (AJAX, Jquery, $.post)

我对我遇到的麻烦完全感到困惑。

我有一个在IIS中托管的网站(处于测试阶段,所以一切都通过本地主机)

IIS 7.5

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

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

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

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

没问题。

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

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

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

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

更新:

这是注册.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;
    ?>

以下是有效的身份验证.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;
    ?>

谢谢

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