Hi Guys

I am trying to send/recieve in json. Whenever I set the dataType to
"json" my BeforeSend, error and success functions don't work. Code
below:

                $.ajax({
                        type: "POST",
                        async: false,
                        dataType: "json",
                        url: _HOMEDIR+"send/",
                        data: { name: nm, email: el, comments: cmt },
                        beforeSend: function() {
                                $("span:last").text("Sending..").show();
                        },
                        error: function() {
                                $("span:last").text("Failed. Please try 
again").show();
                        },
                        success: function(data) {
                                alert("data ");
                                if(data.type == "failed") {
                                        $("span:last").text("Please enter valid 
data for each field").show
();
                                } else {
                                        $("span:last").text("Thank you for your 
message").show();
                                }
                        }
                });

Reply via email to