如何在 Ajax 调用上使路径动态化,当我在本地运行代码时,它只能在 URL 路径为“/WebsiteFolder/assets/mail/contact_me.php”时起作用,并且当它托管在 cPanel 上时,它只能起作用当URL路径为“/assets/mail/contact_me.php”时,如何使路径动态化?
$.ajax({
url: "/WebsiteFolder/assets/mail/contact_me.php",
type: "POST",
data: {
name: name,
phone: phone,
email: email,
message: message,
},
cache: false,
success: function () {
// Success message
},
error: function (xhr, status, error) {
// Fail message
},
complete: function () {
setTimeout(function () {
$this.prop("disabled", false); // Re-enable submit button when AJAX call is complete
}, 1000);
},
});
慕慕森