I'm creating a JSON arrary in Jquery and then sending it to php. In php I decode it but I get an error message. Below is an echo of the array that arrives in php and the error message. Note: I have only passed one item (to keep it smaller but in the further there would be more items in the array:
This is the current PHP code:
print_r($_POST['cropData']);
$cropData = json_decode($_POST['cropData']);
print_r($cropData);
Also here is the jquery to generate the json array:
jsonArray[thumbNum] = [{'src':val.attr('src')},
{'width':val.width()},
{'height':val.height()},
{'dataCX':val.attr('data-cx')},
{'dataCY':val.attr('data-cy')},
{'dataCW':val.attr('data-cw')},
{'dataCH':val.attr('data-ch')}
]
thumbNum++;
}
$.post('scripts/php/join_processing.php', {
'cropJoin': '1',
'cropData': jsonArray},
function(data) {
Any advise on what I'm doing wrong here? I'm I sending an badly formed JSON array or not encoding it correctly?
thx