dimanche 1 mars 2015

run php script with ajax shows no result

I'm trying to run a php script using ajax after a form submission. this is the form



<form id="form" class="form">
<input id="email" type="email" required name="email" placeholder="Email" onchange="myUpdateFunction()" value="">
<textarea id="message" type="text" value="" name="message" onchange="myUpdateFunction()" required placeholder="Comments" style="border:none;border-bottom:1px solid #424242; width:530px;"></textarea>
<input id="submit" type="submit" class="submit" name="send_request" value="Submit" >
</form>


this is my script



$('.submit').on('click', function() {
$.ajax({
url: "send.php",
method:'post',
data: {'email': $('#email').val(), 'message': $('#message').val()}
}).done(function() {
alert('Message Sent.');

});
});


and this is my send.php file



<?php

if(isset($_POST['send_request'])){
//send email
}

?>


but it doens't work, the page is reloaded, the email is not sent and no "alert message" is displayed


Aucun commentaire:

Enregistrer un commentaire