jcadima
5/18/2017 - 3:13 PM

Ajax without serialize - compact

Ajax without serialize - compact



jQuery(function() {
	jQuery("#cta_submit_single").click(function() {
    // here is the whole data object being passed as data in the data field for ajax
		var data = {
		    fullname:  jQuery("#fullname").val(),
		    car_type:  jQuery("#car_type").val(),
		    phone:     jQuery("#phone").val(),
		    email:     jQuery("#email").val(),
		    from:      jQuery("#from").val(),
		    to:        jQuery("#to").val()
		};

        jQuery.ajax({
            type: "POST",
            url: "<?php bloginfo('template_url'); ?>/sendemail.php",
            data: data,
            success: function(msg){
            	jQuery('.success.alert.alert-info.sform').css("display", "block").text(msg);
            	console.log("MESSAGE DETAILS: " + msg ) ;
            },
            error: function(msg){
            	jQuery('.success.alert.alert-info.sform').text("Error");
            	console.log("ERROR MESSAGE: " + msg) ;
            }           
            
        });

        return false;
    });
});	

</script>