I am sending a post data to get a json string back:
My JSON string:
{\"error\":false,\"success\":\"Added Website\",\"website_id\":\"12\"
Try parsing your json string to a json object to get your values:
data = JSON.parse(data);
You haven't provided a dataType
in your $.ajax
, so AJAX treats the response as a string
, not an object. So, inside the success
function, do this first:
success: function(data) {
data = JSON.parse(data);