json data returns invalid label error

felipehyoga

New Member
I'm using Ajax file upload function with its javascript / jQuery library.When uploading a file, I keep getting this error message: \[code\]SyntaxError: invalid label\[/code\] This is my JS script:\[code\] jQuery('.uploadImage').live('click',function() { ajaxFileUpload(); }); (...) function ajaxFileUpload(){ jQuery.ajaxFileUpload({ url:'../wp-content/plugins/wp-filebrowser/uploader.php', secureuri:false, fileElementId:'uploadFile', dataType: 'json', success: function (data, status){ if(typeof(data.error) != 'undefined'){ if(data.error != ''){ alert(data.error); }else{ alert(data.msg); } } }, error: function (data, status, e){ alert(data + ' - ' + status + ' - ' + e); } } ) return false; }\[/code\]My PHP script works (tested before using json / jquery), but there must be something wrong with my json output from my PHP file. I've tried two approaches.I'm using json_encode to format the output. This is some of my PHP code:\[code\] (...) // Error message is at this stage empty. move_uploaded_file($_FILES["file"]["tmp_name"], $uploadfile); $respons = $_FILES["file"]["name"]._e(' successfully uploaded'); $data = http://stackoverflow.com/questions/3672672/array("error"=> $error, "msg"=> $respons ); echo json_encode($data); \[/code\]UPDATE
It turns out that I was using Worpdress's \[code\]_e()\[/code\] for supporting multilanguage. The problem is that \[code\]_e()\[/code\] echo's the content and therefor clutters the JSON response. Once I switched to \[code\]__()\[/code\] it worked.Thanks for helping medebug this poblem guys.
 
Back
Top