Hello I have an ajax request that submits a form and sends and email, if the email is submitted successfully, I encode a PHP array that looks like this,
$success = array("state" => "Email Sent");
I am then checking the state of data
in my ajax request to see if state
matches "Email Sent" however when I alert(data)
i get undefined, what am I doing wrong? Below is my 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);
}
});