Reputation: 60078
I'm trying to make some changes to the way jEditable handles errors. I have a PHP function which is returning:
echo "{'error':'ok', 'error_msg':'There was a problem'}";
in my javascript:
"callback": function( sValue, y )
{
if (sValue == "ok")
{
alert ("ok");
}
else
{
alert ("error");
}},
Now I keep getting the "error" alert on my screen - no matter what I try. Obviously the problem is at this line:
if (sValue == "ok")
but I'm not sure what it is supposed to be? I've looked at other examples on StackOverflow - but couldnt get one that answered my question.
Upvotes: 0
Views: 462
Reputation: 27765
Seems that you need to parse JSON and get error
value from parsed object:
"callback": function (data, y) {
var errorData = $.parseJSON(data);
if (errorData.error == "ok") {
alert("ok");
} else {
alert("error");
}
},
Upvotes: 2