mysqli_query($con, $sql)
mysqli_close($con);
}
How to use AJAX with PHP
Here is a good answer with a good example. jQuery Ajax POST example with PHP
Also you might want to learn more about basics before going further. Try to google ajax, php ajax mysql and find some tutorials.