ajax json response from PHP not recognized
PHP server:
$result = array(); //declare empty array
$result['error']='';
$result['result']=1;
$result['crud']='E';
echo json_encode($result);
===================================
AJAX
$.ajax(
{
url : "xxxx.php",
method: "POST",
data : value,
dataType : "JSON",
success: function(response, status, xhr)
{
var crudType = response.crud;
var dataResult = response.result;
if((crudType == 'E') && (dataResult == 1))
{
-- something --
} else
{-- something -- }
},
error: function(jqXHR, textStatus, errorThrown)
{
alert("Error!");
}
});
====================================
response payload:
{"error":"","result":1,"crud":"E"}
====================================
Problem: ajax always says "Error!"...and does not go into the "success" path of code..
What am I doing wrong here ?