Upload image with datauri as source empty on ajax post call

153 views Asked by At

Hi Guys i cropped my image using jcrop and i have the data_uri for the cropped imaged i have collated them all into an array but it seems the array could not be passed when i make my ajax request as the array is empty in the php. here's my code below

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

There are 1 answers

6
S.Pols On

Try to stringify your array:

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
    }
)