function submitForm(form) {
    var url=$("#" + form).attr('action');
    var data=$("#" + form).serialize();
    $.ajax({
      type: 'POST',
      url: url,
      data: data,
      success: successfun,
      error: errorfun,
      dataType: "json"
    });
    return false
}
function errorfun(responseText, statusText, xhr, form) {
   alert("Action unsuccessful. Try again later.")
}
function successfun(responseText, statusText, xhr, form) {
    for (var key in responseText) {
        if (responseText[key].name == "ok") {
            if ($("#auto_update_cache_checkbox").attr("checked")) {
                $.modaldialog.success(responseText[key].value + "n" + "\u9759\u6001\u9875\u9762\u66f4\u65b0\u4e2d...");
                updateCache($("#auto_update_cache_checkbox").val(), "")
            } else {
                $.modaldialog.success(responseText[key].value)
            }
        } else {
            if (responseText[key].name == "ok_go") {
                setTimeout(function () {
                    window.location.href = responseText[key].value
                }, 2000)
            } else {
                if (responseText[key].name == "no") {
                    $.modaldialog.error(responseText[key].value)
                } else {
                    if (responseText[key].name == "go") {
                        window.location.href = responseText[key].value
                    } else {
                        if (responseText[key].name == "ok_modal") {
                            $(".modal").modal("hide");
                            $.modaldialog.success(responseText[key].value)
                        } else {
                            if (responseText[key].name == "no_modal") {
                                $(".modal").modal("hide");
                                $.modaldialog.error(responseText[key].value)
                            } else {
                                var url = window.location.href;
                                window.location.href = url.replace(/#warning/g, "") + "#warning";
                                showTips(responseText[key].name, responseText[key].value)
                            }
                        }
                    }
                }
            }
        }
    }
    return true
}

function showTips(objName, title) {
    $("#" + objName).tooltip({
        title: title,
        placement: "top",
        trigger: "manual"
    });
    $("#" + objName).tooltip("show");
    setTimeout(function () {
        $("#" + objName).tooltip("hide")
    }, 3000)
}