I am using following jQuery code to submit a form via AJAX.
jQuery('form.AjaxForm').submit( function() {
$.ajax({
url : $(this).attr('action'),
type : $(this).attr('method'),
dataType: 'json',
data : $(this).serialize(),
success : function( data ) {
alert('Submitted')
},
error : function( xhr, err ) {
alert(''Error);
}
});
return false;
});
Code is working perfectly with no ajax. But does not work if I load form via ajax. I think it is because of loading form via ajax after JavaScript load.
Any solution?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…