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

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -