Insert data through ajax into mysql database

后端 未结 6 1182
灰色年华
灰色年华 2020-11-30 06:33

Newsletter:

\">
6条回答
  •  情话喂你
    2020-11-30 06:53

    The available answers led to the fact that I entered empty values into the database. I corrected this error by replacing the serialize () function with the following code.

    $(document).ready(function(){
    
    // When click the button.
    $("#button").click(function() {
    
        // Assigning Variables to Form Fields
        var email = $("#email").val();
    
        // Send the form data using the ajax method
        $.ajax({
            data: "email=" + email,
            type: "post",
            url: "your_file.php",
            success: function(data){
                alert("Data Save: " + data);
            }
        });
    
    });
    
    });
    

提交回复
热议问题