美文网首页
ajax Get/Post 提交

ajax Get/Post 提交

作者: 小瞪瞪 | 来源:发表于2018-09-01 11:08 被阅读0次

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

相关文章

网友评论

      本文标题:ajax Get/Post 提交

      本文链接:https://www.haomeiwen.com/subject/lvrswftx.html