0

我正在使用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;
}
4

2 回答 2

0

试试这个:

$('#form').submit(function (e) {
  e.preventDefault();
  //your code
});
于 2012-08-01T08:46:21.457 回答
0

导致重定向的原因是:

window.location.href = rt.Data;

评论它或用 alert('success') 或其他东西替换它。

于 2012-08-01T09:11:02.433 回答