I used preventDefault
on my form and I am trying to use this to automatically submit when a statement is true.
function codeCheck(){
$("#code-form").submit(function(e){
e.preventDefault();
});
var code = $("#code").val();
$.ajax({
url: "index.php",
type: "POST",
data: { codeCheck: 1, ajaxCode: code }
}).done(function(check) {
if(check == 2){
$("#used").css("display", "block");
}
else if(check == 1){
$("#code").css('background', "url('../img/check.png') no-repeat scroll 170px 2px");
$("#submit").css('display', 'block');
$("#submit").on("click", function(){
$( "#container" ).fadeOut( "slow", function() {
$("#code-form")[0].submit();
});
});
$("#used").css("display", "none");
}
else{
$("#code").css('background', "none");
$("#used").css("display", "none");
//$("#code-form").unbind('submit');
}
});
}
The unbind does work I can use the submit button when I unbind it. But the $("#form").submit()
part doesn't work it doesn't submit the form automatically after fading out.
Here is a fiddle: http://jsfiddle.net/90wmpw7x/1/
All I want is that it continues the form after the fade.
EDIT: For more clarity I just added the full function.