php – The Ajax script does not hide the modal context menu – $ ("# dataModal"). modal (& # 39; hide & # 39;);

I have a form that is inserted into a Modal Bootstrap code. When values ​​are entered in the input fields, the Ajax script passes them to a php file and sends them back with a success alert. In fact, only the alert appears, but when you click the OK button of this alert, Modal does not close. You will find below the code of the Modal context menu and the Ajax script:





Below is the Ajax script that passes the value of the input to the insert.php file which, in case it works correctly, inserts the data into the database:


And finally, the code of the file insert.php:

<? php
$ servername = "localhost";
$ username = "root";
$ password = "";
$ basename = "system";

// create a connection
$ conn = mysqli_connect ($ servername, $ username, $ password, $ dbname);
// check the connection
if (! $ conn) {
die ("The connection failed:". mysqli_connect_error ());
}
$ name = $ _POST['nome'];
$ email = $ _POST['email'];
$ sql = "INSERT INTO users (name, email)
VALUES ($ name, # "email") ";

if (mysqli_query ($ conn, $ sql)) {
echo "New record created successfully";
} else {
echo "Error:". $ sql. "
"mysqli_error ($ conn); } mysqli_close ($ conn); ?>

What's going on, is that the Modal popup does not close despite the code $ ("# dataModal"). modal (& quot; Hide & quot;) to be after the alert and not to "zero" the input fields $ ("# userform")[0].reset (); after the result of the success. The data is entered normally after clicking "ok" on the screen of the alert message. What can it be? Thank you