mysqli_real_escape_string use with ajax
jQuery(document).ready(function($){
// hide messages
$("#error").hide();
$("#sent-form-msg").hide();
// on submit...
$("#contactForm #submit").click(function() {
$("#error").hide();
//required:
//name
var name = $("input#name").val();
if(name == ""){
$("#error").fadeIn().text("Name required.");
$("input#name").focus();
return false;
}
// email
var email = $("input#email").val();
if(email == ""){
$("#error").fadeIn().text("Email required");
$("input#email").focus();
return false;
}
// contact_no
var contact_no = $("input#contact_no").val();
if(contact_no == ""){
$("#error").fadeIn().text("Contact number required");
$("input#contact_no").focus();
return false;
}
// comments
var comments = $("#comments").val();
// data string
var dataString = 'name='+ name
+ '&email=' + email
+ '&contact_no=' + contact_no
+ '&comments=' + comments
// ajax
$.ajax({
type:"POST",
data: dataString,
success: success()
});
});
// on success...
function success(){
$("#sent-form-msg").fadeIn();
$("#contactForm").fadeOut();
}
return false;
});
Also in JavaScript:
- build an api in nodejs using express to send emails using the gmail rest api without client libraries
- install node modules in an existing project
- javascript array remove
- vars javascript
- javascript collection processing methods
- 'ts-node' não é reconhecido como um comando interno ou externo, um programa operável ou um arquivo em lotes.
- javascript number to string
- is a letter javascript
- javascript print
- jquery links
- jquery set title attribute
- javascript equality
- javascript reverse each string element in array
- how to get a toggle button to do different js functions
- can you get reinfected with the coronavirus
- js map don't return
- sort array based on another array
- jquery wrap inner text
- javascript break foreach
- javascript detect enter press on input
- pip install json
- mathematically create bezier curve javascript
- flutter asset image not showing
- import jquery google cdn