I follow this tutorial:
<a href="http://samsonasik.wordpress.com/2012/10/11/zend-framework-2-using-zend-form-and-ajax/" rel="nofollow">http://samsonasik.wordpress.com/2012/10/11/zend-framework-2-using-zend-form-and-ajax/</a>
I dont want to popup in my code so as per above tutorial code call showform action direct by localhost/ajax_demo/public/testajax/skeleton/showform . while submit this form its call validatepostajax function two time means validate two times and also save data into database two times.
Please help me how to prevent it for submit and validate only for one time.
Thanks in Advance..
My ajax form code is:
This code is developed on reference above link, but it execute two times. so how can i call it only one time.
<a href="http://samsonasik.wordpress.com/2012/10/11/zend-framework-2-using-zend-form-and-ajax/" rel="nofollow">http://samsonasik.wordpress.com/2012/10/11/zend-framework-2-using-zend-form-and-ajax/</a>
I dont want to popup in my code so as per above tutorial code call showform action direct by localhost/ajax_demo/public/testajax/skeleton/showform . while submit this form its call validatepostajax function two time means validate two times and also save data into database two times.
Please help me how to prevent it for submit and validate only for one time.
Thanks in Advance..
My ajax form code is:
Code:
$(function(){
$("form#loginform").submit(function(){
$.post(url_loginform,
{ 'username' : $('input[name=username]').val(),
'password' : $('form#loginform input[name=password]').val(),
'agree' : $('form#loginform input[type=checkbox]').val()
}, function(itemJson){
$('.error').remove();
$('.success').remove();
/*Check error exist or not For each form element and set validation messages HTML*/
var error = false;
if (!error){
if (itemJson.success == 1){
$("#loginform").prepend('<li class="success">Login Successfully</li>');
}
}
/*Invalid Credentials*/
if (itemJson.error == 1){
$("#loginform").prepend('<li class="error">Invalid Credentials</li>');
}
}, 'json');
return false;
});
});
This code is developed on reference above link, but it execute two times. so how can i call it only one time.