Untitled

 avatar
unknown
plain_text
a month ago
899 B
4
Indexable
$(document).ready(function() {
    $("#submitBtn").click(function(e) {
        e.preventDefault(); // Prevent default form submission

        var formData = new FormData($("#myForm")[0]); // Get form data

        $.ajax({
            url: "process.php",
            method: "POST",
            data: formData,
            processData: false,
            contentType: false,
            dataType: "json",
            success: function(response) {
                if (response.status === "success") {
                    $("#responseMessage").html(
                        response.message + "<br>" +
                        response.carMessage + "<br>" +
                        response.preferredCarsMessage
                    ).show();
                }
            },
            error: function() {
                alert("Failed to process the request.");
            }
        });
    });
});
Editor is loading...
Leave a Comment