Is there a way to incorporate ajax within this particular "if statement"?
if (code) {
drawLine(code.location.topLeftCorner, code.location.topRightCorner, "#FF3B58");
drawLine(code.location.topRightCorner, code.location.bottomRightCorner, "#FF3B58");
drawLine(code.location.bottomRightCorner, code.location.bottomLeftCorner, "#FF3B58");
drawLine(code.location.bottomLeftCorner, code.location.topLeftCorner, "#FF3B58");
// Here is where I want to implement an ajax call and visit a url like the one below
$.ajax({
url: "save.php",
type: "POST",
data: {
type: 1,
name: name,
email: email
},
cache: false,
success: function(dataResult){
var dataResult = JSON.parse(dataResult);
if(dataResult.statusCode==200){
/// Proceed with my code in case of success
}
else if(dataResult.statusCode==201){
/// Execute a different set of instructions for failure.
}
}
});
} else {
Also, how can I validate if a specific input contains exactly 6 characters/numbers using JavaScript? If so, then I would like to execute a similar ajax function but outside of the displayed if statement.