简体   繁体   English

发送邮件时出现错误404

[英]Error 404 when I send a mail

I spent a lot of time on this bug, can someone notice what the reason is? 我花了很多时间解决这个错误,有人可以注意到原因吗?

The Mail.php file is located in the project root. Mail.php文件位于项目根目录中。

//E-mail Ajax Send
$("form").submit(function() { //Change
    var th = $(this);
    $.ajax({
        type: "POST",
        url: "/mail.php", //Change
        data: th.serialize()
    }).done(function() {
        alert("Thank you!");
        setTimeout(function() {
            // Done Functions
            th.trigger("reset");
        }, 1000);
    });
    return false;
});

But it returns a 404: 但它返回404:

屏幕截图

You can use either the absolute or relative path as stated above in comments. 您可以使用上面注释中所述的绝对路径或相对路径。 For your particular case, if both the files in same directory as you stated, just use "mail.php" no "/mail.php". 对于您的特定情况,如果两个文件都与您声明的目录位于同一目录中,则只需使用“ mail.php”而不是“ /mail.php”。

url: "mail.php", // in place of "/mail.php"

Alternatively you can use the url path like the below: 或者,您可以使用如下所示的url路径:

url: "www.example.com/mail.php", 

Hope this fix your 404 error 希望这能解决您的404错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM