Search code examples
javascriptasp.netblogengine.net

Prevent redirecting after saving post in blogengine


I am using BlogEngine as my blogging platform and I would like to know if there is a way to prevent the post redirect action after I am saving my post, I tried to debug the code but couldn't find the redirect action.

this is the save post method in the client side:

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;
}

Solution

  • What causes redirecting is:

    window.location.href = rt.Data;
    

    Comment it or replace it with alert('success') or something else.