ajax Get/Post 提交

GET提交:

function del(id){

var _href ="/group_del?id="+id;

    layer.open({

shade:false,

        content:'确定删除?',

        btn: ['确定', '取消'],

        yes:function (index) {

$.ajax({

url: _href,

                type:"get",

                success:function (info) {

if (info.code ===1) {

setTimeout(function () {

location.href ="/group";

                        }, 1000);

                    }

layer.msg(info.msg);

                }

});

            layer.close(index);

        }

});

}


POST:



function add() {

var name=$("input[name='name']").val();

    var token=$('meta[name="csrf-token"]').attr('content');

    var url="/group_add";

    $.ajax({

url:url,

        dataType:'json',

        type:'post',

        data: {'name':name,"_token":token},

        async:false,

        success:function (info) {

if (info.code ===1) {

setTimeout(function () {

location.href ="/group";

                  }, 1000);

              }

layer.msg(info.msg);

        },error:function (e) {

//console.log(e.status)

        }

});

}


php



©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容