【发布时间】:2012-10-28 19:33:04
【问题描述】:
我有一个 HTML.ActionLink 正在查看。我正在做的是调用$.ajax() 函数,该函数检查来自anction 的返回真或假。它击中动作,返回所需的结果真/假。但问题是当它返回 false 时。我需要显示一个alert 并且重定向应该只在它返回 true 的情况下..
ActionLink:
<%: Html.ActionLink("Add Race", "AddRace",
new {eventId = Model.EventId, fleetId=Model.SelectedFleet.ID},
new{onclick="return checkFleetAddedandScroing()"}) %>
功能:
function checkFleetAddedandScroing() {
debugger;
$.ajax({
type: "GET",
url: '<%=Url.Action("CheckFleetExists", new {eventId=Model.EventId})%>',
dataType: "json",
cache: false,
success: function (data, textStatus) {
data = eval("(" + data + ")");
if (data == true) {
alert('Ok button clicked');
return true;
}
else {
alert("Cannot delete this fleet becasue either you have already added races to this event or the fleet has used for boat registration.");
return false;
}
}, //success
error: function (req) {
}
});
}
它总是重定向..它是否返回真/假..只有当它返回真时才应该重定向....
请纠正我做错的地方..
【问题讨论】:
标签: asp.net-mvc-3 jquery html.actionlink