jquery post problem with callback – Education Career Blog

I can’t get any callback data:

    <script type="text/javascript">
jQuery(function(){
jQuery("#JqPostForm").submit(function(){
        jQuery.post("index.php?option=comp&task=sendemail", jQuery("#JqPostForm").serialize(),

        function(data){
        alert('ok');
            if(data.email_check == 'invalid'){

                    jQuery("#message_post").html("<div class='errorMessage'>Sorry " + data.name + ", " + data.email + " is NOT a valid e-mail address. Try again.</div>");
            } else {
                jQuery("#message_post").html("<div class='successMessage'>" + data.email + " is a valid e-mail address. Thank you, " + data.name + ".</div>");
                }
        }, "json");

        return false;

});
});
</script>

The echo in php function is: echo json_encode($return_arr); which is: {"email_check":"invalid","name":null,"email":null}

but can’t get it working i’m developing on localhost and firefox

,

Make sure that the server sends the appropriate content type:

header('Content-type: application/json');

Leave a Comment