I trie to get an json in my jquery ajax successe: to worke but i dose not.......
Thats what i tried to do:
$("#addcatform").submit(function() {
var str = $(this).serialize();
$.ajax({
type: "POST",
url: "ajax.php",
data: str,
success: function(data){
var json_x = data;
alert(json_x.firstName2);
$('#result').html(json_x.firstName2);
$('#result2').html(json_x.b);
}
});
return false;
event.preventDefault();
}); // submit end
the php echos this:
$arr = array ('firstName2'=>'hallo','b'=>2,'c'=>3,'d'=>4,'e'=>5);
echo json_encode($arr);
Whats wrong with this? Thanks for helping!!!!