405 (Method Not Allowed) on AJAX request only when using DNS

丶灬走出姿态 提交于 2019-12-31 04:15:12

问题


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();
    }
});

回答1:


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



来源:https://stackoverflow.com/questions/18701404/405-method-not-allowed-on-ajax-request-only-when-using-dns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!