AJAX Code:-
$("#email").change(function(){
alert('email changed');
var Email = {
email: $('#email').val()
}
var formsubmission = 'http://127.0.0.1/heropet/Common/check_mail';
$.ajax({
method: "POST",
url: formsubmission,
data: Email,
success: function(response){
alert(response);
}
});
HTML Code:
<label>E-mail</label>
<input type="text" name="email" id="email" value=""><br>
I don't know but it not making AJAX request in XAMPP Web server. How can I resolve this error? And sorry for my weak English.
Error:-
1.closing });missed of $("#email").change(function(){
Working example code:-
$("#email").change(function(){
alert('email changed');
var Email = $('#email').val();
var formsubmission = 'http://127.0.0.1/heropet/Common/check_mail';
$.ajax({
method: "POST",
url: formsubmission,
data: {email:Email},
success: function(response){
alert(response);
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label>E-mail</label>
<input type="text" name="email" id="email" value=""><br>
Note:- add a proper jquery library as i have added into my example.
You are missing "})" at the end.
Also wrap it in $( document ).ready(function(){})
As shown below:
$( document ).ready(function(){
$("#email").change(function(){
alert('email changed');
var Email = {
email: $('#email').val()
}
var formsubmission = 'http://127.0.0.1/heropet/Common/check_mail';
$.ajax({
method: "POST",
url: formsubmission,
data: Email,
success: function(response){
alert(response);
}
});
});
});