json两种方式传值

     $.ajax({

                type: "POST",

                url: "{:url('Index/pick')}",

                data: $('#handleposition').serialize(),

                dataType: "json",

                error: function () {

        alert('操作失败');

    },

                success: function (data) {

                    if (data.status == 1) {

                        layer.msg(data.msg, {icon: 1, anim: 0, time: 2000});

                                            

                    } else {

                        layer.msg(data.msg, {icon: 2, anim: 0, time: 2000});

                            // window.location.reload();

                    }

                }

            });

    

            var url = "{:url('Index/pick')}";

            var datas = $('#handleposition').serialize();

            jq.getJSON(url,datas,function(data){

                        

                    if (data.status == 1) {

                        layer.msg(data.msg, {icon: 1, time: 3000}, function(){                  

                            window.location.reload();

                            });

                                                

                        } else {

                            // layer.msg(data.msg, {icon: 2, anim: 0, time: 2000});

                            layer.msg(data.msg, {icon: 2, time: 3000}, function(){                  

                            window.location.reload();

                            });

                                // window.location.reload();

                        }

                 });

猜你喜欢

转载自blog.csdn.net/lmp5023/article/details/88636994