zoukankan      html  css  js  c++  java
  • 我所常用的ajax调用格式

    ajax:

    $.ajax({
        type: "post",
        datatype: "json",
        contentType: "application/x-www-form-urlencoded; charset=UTF-8",
        url: "/ProductTypeAndCat/AddType",
        async: true,
        cache: false,
        data: { typeName: typeName },
        success: function (data) {
            if (data.F == 1) {
                alert(data.M);
                return;
            }

            alert("添加成功!");
            location.href = "/Admin/ProductType";
        },
        error: function (xhr, status, error) {
            alert(error);
        }
    });

    form提交,利用此插件(http://jquery.malsup.com/form/):

    $('#frmDemo').ajaxSubmit({
        type: "post",
        url: "/ProductTypeAndCat/AddCategory",
        success: function (data) {
            if (data.F == 1) {
                alert(data.M);
                return;
            }

            alert("添加成功");
            location.href = "/admin/createProductCategory";
        },
        error: function (xhr, status, err) {
            alert(err);
        }
    });

  • 相关阅读:
    R并行计算
    VMware虚拟机安装linux系统
    爬虫资料
    R-shiny服务器安装及配置
    数模国赛——致病基因
    vs 2013远程调试
    获取url的hash值
    JavaScript调试技巧之console.log()详解
    无法打开登录所请求的数据库
    location.host 与 location.hostname 的区别
  • 原文地址:https://www.cnblogs.com/luminji/p/4741840.html
Copyright © 2011-2022 走看看