If i have this json response
{"error":"repeated"}
Why the alert is not showed? It is needed put somewhere dataType: "json" ?
$(function () {
$("#box a").click(function () {
var selectedId = $(this).attr("class");
$.post("new_list.php", {
id_user: <?php echo $id;?>,
id_list: selectedId
}, function (data) {
if(data.error == 'repeated') {
alert("error");
}
});
});
});
thanks
It’s not going to automatically parse it as JSON unless you tell it to.