我在加载网站时遇到问题。使用此代码:
$.ajax({
type: "POST",
//url: '@Url.Action("/TellFriendPopup")',
url: '/Property/TellFriendPopup',
data: { "SenderName": SenderName, "senderMail": senderMail, "receiverMail": receiverMail, "comments": comments, "urlLink": urlLink, "subjectId": subjectId },
success: function (data) {
$("#result").html("<ul><li>Name: " + data.nameret + "</li><li>Email: " + data.emailret + "</li><li>Message: " + data.messageret + "</li></ul>");
$(".dialog").dialog("close");
},
问题是我必须将代码移动到 JavaScript 文件,而不是 MVC4 视图,我可以在其中使用该@Url.Action
方法。但它不适用于 JavaScript。它只是给了我这个错误POST http://localhost:54717/Property/ContactPopup 404 (Not Found)
。如我所见,原因是它缺少全球化。因为网址应该看起来像这样 http://localhost:54717/da/Property/ContactPopup
或 http://localhost:54717/en/Property/ContactPopup