仅在使用 DNS 时 AJAX 请求上的 405(不允许的方法) [英] 405 (Method Not Allowed) on AJAX request only when using DNS

查看:17
本文介绍了仅在使用 DNS 时 AJAX 请求上的 405(不允许的方法)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常奇怪的问题,我使用 AJAX 从我的 html 页面发送电子邮件,该页面链接到我在同一网站中的 PHP 页面.当我以 IP 模式1xx.xx.xxx.xxx:8080/mywebsite 进入网站时,AJAX 请求工作正常,只有当我使用链接到该 IP 地址的 DNS 时,才会出现此错误:

POST http://www.mywebsite.ma/sendEmail.php 405(方法不允许)

这是 AJAX 请求:

$.ajax({类型:POST",url: "sendEmail.php",数据:datastr,缓存:假,成功:功能(html){如果(html ==成功"){庆祝TheSuccessOfThisEmailSending();} 别的 {杀了我自己();}},错误:函数(){sumTingWong();}});

解决方案

我终于找到了问题所在,不知道是不是因为我对 Servers 和其他东西缺乏经验而没有看到.长话短说:我在服务器上安装了 Wamp,我使用 IP+端口来访问它,但是当我使用 DNS 时它直接指向网站文件(包括 php 文件)而它没有不经过Wamp.

我最终卸载了 Wamp 并将 PHP 包含在我的 IIS 服务器中以直接编译 PHP 文件,而无需安装另一台服务器.

我遵循了本教程 -> 如何在 Windows Server 2008 的 IIS 7 上安装 PHP

I have a really weird problem, I use AJAX to send an email from my html page, which links to a PHP page I have within the SAME website. The AJAX request works fine when I enter the website in IP mode 1xx.xx.xxx.xxx:8080/mywebsite only when I use a DNS that links to this IP address I get this error :

POST http://www.mywebsite.ma/sendEmail.php 405 (Method Not Allowed)

Here's the AJAX request :

$.ajax({
    type: "POST",
    url: "sendEmail.php",
    data: datastr,
    cache: false,
    success: function(html){
        if (html == "success"){
            celebrateTheSuccessOfThisEmailSending();
        } else {
            killMySelf();
        }
    },
    error: function() {
        sumTingWong();
    }
});

解决方案

I finally found the problem, I don't know how I didn't see due to my lack of experience with Servers and stuff. Long story short : I installed Wamp on the server, I used the IP+Port to access it, but when I use the DNS it directly points to the website files(including php files) and it didn't go through Wamp.

I ended up uninstalling Wamp and including PHP in my IIS server to directly compile PHP files without the need to install another server.

I followed this tutorial -> How to Install PHP on IIS 7 for Windows Server 2008

这篇关于仅在使用 DNS 时 AJAX 请求上的 405(不允许的方法)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆