我正在使用BlogEngine作为我的博客平台,我想知道在保存帖子后是否有办法阻止帖子重定向操作,我试图调试代码但找不到重定向行动。
这是客户端的保存帖子方法:
function SavePost() {
$('.loader').show();
var content = document.getElementById('<%=txtRawContent.ClientID %>') != null ? document.getElementById('<%=txtRawContent.ClientID %>').value : tinyMCE.activeEditor.getContent();
var title = document.getElementById('<%=txtTitle.ClientID %>').value;
var slug = document.getElementById('<%=txtSlug.ClientID %>').value;
var photo = document.getElementById('<%=txtPostPhoto.ClientID %>').value;
var kind = $("[id$='ddlKind'] option:selected").val();
var isPublished = $("[id$='cbPublish']").is(':checked');
var date = document.getElementById('<%=txtDate.ClientID %>').value;
var time = document.getElementById('<%=txtTime.ClientID %>').value;
var dto = {
"id": Querystring('id'),
"content": content,
"title": title,
"slug": slug,
"postPhoto": photo,
"kind": kind,
"isPublished": isPublished,
"date": date,
"time": time
};
//alert(JSON.stringify(dto));
$.ajax({
url: SiteVars.ApplicationRelativeWebRoot + "admin/AjaxHelper.aspx/SaveMiniPost",
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(dto),
beforeSend: onAjaxBeforeSend,
success: function (result) {
var rt = result.d;
if (rt.Success) {
if (rt.Data) {
window.location.href = rt.Data;
} else {
ShowStatus("success", rt.Message);
}
} else ShowStatus("warning", rt.Message);
}
});
$('.loader').hide();
return false;
}
答案 0 :(得分:0)
试试这个:
$('#form').submit(function (e) {
e.preventDefault();
//your code
});
答案 1 :(得分:0)
导致重定向的原因是:
window.location.href = rt.Data;
评论或用警报('成功')或其他东西替换它。