I have this jQuery code which use $.post for Ajax:
$.post(ajax_url , { upload_id: upload_id },
function (response) {
console.log(response);
console.log(jQuery.type(response));
}, "json");
and the php code :
$data = Array(
'status' => '1',
'msg' => '',
'progress' => '0.24',
'time' =>'<span class="text-white">06:51</span> left (at 21KB/sec)',
'size' => '<span class="text-white">26KB</span> / 10.91MB (0.24%)');
echo json_encode($data);
die();
and it suppose the console print the json code and the type which is json.
the problem is not print any thing in the console, it means no response.
I put this in the Ajax code to see the error:
.fail( function(jqXHR, textStatus, errorThrown) {
alert(textStatus)});
and the alert was parsererror.
what is the problem ?
UPDATE
If I removed "json"
from the ajax code, the response print the type string
and the code {"status":1,"msg":"","progress":"0.15","time":"<span class=\"text-white\">11:11<\/span> left (at 10KB\/sec)","size":"<span class=\"text-white\">16KB<\/span> \/ 10.91MB (0.15%)"}
I need it json