It's getting reload because it's a submit
button and that is added inside form
so it's submitting the form on click without waiting for AJAX to get submitted.
You can use preventDefault() jQuery method to stop the page redirect. Like this,
$('#submit').click(function(e) {
e.preventDefault();
var data = {
name: $("#name").val(),
email: $("#email").val(),
message: $("#msg").val()
};
$.ajax({
url: '../send_mail.php',
type: 'POST',
data: data,
success: function(msg) {
alert('Email Sent');
}
});
});
When preventDefault(); method is called, the default action of the event will not be triggered.
You've also missed quotes to specify URL in .ajax().
jsFiddle: https://jsfiddle.net/3Lpft17y/