3
How to take the JSON value with ajax and define the behavior, which div and which message to display, for example:
If the JSON returns {"error":"true","message":"Algo deu errado"}
would display any div, "error" for example, with the message that JSON returned, being that JSON can return multiple messages...
Another example of usage is to delete information and "remove" the div with some fade out effect, the ID being generated automatically, e.g.: <div id="item-52">
, if all goes well {"error":"false","message":"Removido com sucesso"}
the DIV would be hidden. How can I do this?
jQuery(document).ready(function(){
jQuery('#ajax_form').submit(function(){
var dados = jQuery( this ).serialize();
jQuery.ajax({
type: "POST",
url: "teste.php",
data: dados,
success: function( data )
{
alert( data );
}
});
return false;
});
});