javascript - JSON returning as undefined -
hello have ajax request submits form , sends , email, if email submitted successfully, encode php array looks this,
$success = array("state" => "email sent");
i checking state of data in ajax request see if state matches "email sent" when alert(data) undefined, doing wrong? below javascript,
$.ajax({ url: "<?php echo base_url(); ?>home/callback", data: $("#callback").serialize(), type: "post", datatype: "json", success: function(data){ $("#fancybox-content div").html(data); alert(data.state); } });
try html value of 'fancybox-content' div. $('#fancybox-content').html();
Comments
Post a Comment