Как правильно отправить и принять json массив?
$response = json_encode(array('foto'=>"$nam",'success'=>"1"));
echo $responce;
<script language="javascript" type="text/javascript">
$(function()
{
var btnUpload=$('#upload');
var status=$('#status');
new AjaxUpload(btnUpload, {
action: 'upload-file.php',
name: 'uploadfile',
onSubmit: function(file, ext)
{
if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext))){
// extension is not allowed
status.text('Only JPG, PNG or GIF files are allowed');
return false;
}status.text('Uploading...');
},
onComplete: function(file, response)
{
//On completion clear the status
status.text('');
//Add uploaded file to list
var obj = JSON.parse('response'); ??????
//var bb=response.substr(0,7)
//var idd=response.replace('success',' ');
//var idb =idd.replace(/^\s*|\s*$/g,'');
if(obj.success == "1")
{
$('<span id='+idd+'></span>').appendTo('#files').html('<img src="images/'+obj.foto+'" alt="" width="120" height="120" style="margin:5px;" /><br><a href="javascript:void(0)" onClick="deleteFile('+idd+');">Delete</a>').addClass('success');
}
else
{
$('<span></span>').appendTo('#files').text(obj).addClass('error');
}
}});
});