My problem is somewhat similar to cakephp, jquery, .ajax (), dataType: json , but my observations are slightly different.
I am working on a Cake PHP project. Consider the group_assocmodule submodule opstools. So there is a function group_assoc()inside opstools_controller.phpthat is called by an ajax call to update group associations.
My ajax post is as follows:
$.post( url,
function(data)
{
if(data)
{
alert(data.success); //alerts -> undefined
alert(data); //alerts -> {"success":true} or {"success":false}
if(data.success)
{
//does not work
}
}
}, "json");
And inside opstools_controller.phpI have -
function group_assoc()
{
...
...
...
...
$success
echo json_encode(array("success" => $success));
}
So, inside the Ajax response handler function (in terms of sending ajax), I get the line as {"success":false}.
. , Ajax- json_encode, Core PHP ( Cake PHP). ? ?
? ? , , . header("HTTP/1.1 200 OK"); , Ajax.
, $this->autoRender = false; .