首页 > 代码库 > ajax 传递数组与接收

ajax 传递数组与接收

//ajax部分
$(function(){
    $(‘#bm‘).click(function(){
        var zhi = $(‘.ybm‘).html();
        var pid = $(‘#pid‘).val();
        $.ajax({
            type:"post",
            traditional: true,
            url:"{:U(‘Home/Project/bm‘)}",
            data: {"zhi":zhi,"pid":pid},
            dataType:"json",
            success:function(data){
                $(‘.ybm‘).html(data);
            }
        })
    })
});

//php部分
$data = http://www.mamicode.com/$_POST;>‘zhi‘] + 1;
$pid = $data[‘pid‘];
$user = M(‘project‘);
$k[‘click‘] = $zhi;
$user->where("pid = $pid")->save($k);
echo $zhi;

 

ajax 传递数组与接收