In php i created an array named :
$errorsa = array();
Then for each error i add it something values in array by something like this :
$errorsa[] = array("id"=>"rules","error"=>"You need to agree to rules");
Then at the end of the file i do this :
echo json_encode($errorsa);
Then in my main file i do something like this :
$("#submiter").click(function() {
$.post("submit.php",
$("#formmain").serialize(),
function(data) {
$.each(data,function() {
$("#result").append(this.error);
});
},
"json"
)
});
But this aint working ?
I am new to json and looking forward on it.
What have i dont wrong in this ?
try something like this:
php:
JS: