如何在函数中返回ajax success json数组

时间:2017-09-10 11:08:56

标签: javascript jquery ajax

function add_to_cart(product_id,sub_product_id,period,type,description){
    var product_id=product_id;
    var sub_product_id=sub_product_id;
    var period=period;
    var type=type;
    var description=description;
    var add_to_cart="YES";
        $.ajax({
        url:'libraries/ajax.php',
        data:{
                product_id:product_id,
                sub_product_id:sub_product_id,
                period:period,
                type:type,
                description:description,
                add_to_cart:add_to_cart,

                },
        type:'POST',
        success:function(data){



            var obj = JSON.parse(data);
            return obj;

            }
        });
}
var returnValue = add_to_cart(2,sub_pro_id,1,"HOSTING",description);
alert(returnValue.return_value);

从数组中调用Return对象 如何在函数中返回ajax success json数组?我想得到返回json数组并像上面那样调用

0 个答案:

没有答案