在ajax post调用上将datauri作为源空上载图像

时间:2014-11-26 10:01:35

标签: php jquery ajax data-uri

嗨大家我使用jcrop裁剪我的图像,我有裁剪图像的data_uri我已将它们全部整理成一个数组但是当我发出我的ajax请求时,似乎数组无法传递,因为数组是空的PHP。这是我的代码

JS

var cropped_images = {/**array of data_uris **/};
console.log(cropped_images); // still have my array intact
    $.post(url,cropped_images,function(data){
        console.log(data) //empty
    }
)

PHP

public function url_from_ajax()
{
   this->view = false;
   return json_encode($this->input->post()) //i'm using codeigniter so the post format is valid
}

1 个答案:

答案 0 :(得分:0)

尝试对您的数组进行字符串化处理:

var cropped_images = {/**array of data_uris **/};
var jsonImages = JSON.stringify(cropped_images);
console.log(cropped_images); // still have my array intact
console.log(jsonImages); // still have my array intact
    $.post(url,jsonImages,function(data){
        console.log(data) //empty
    }
)