javascript - jquery ajax action when there is no error -
i not understand off logic. have typical form use ajax submit data.
$('#contactform').on('submit',function(e){ var formmsg = $('#contactformreturnmsg'); formmsg.empty(); e.preventdefault(); $.post('contact.php', $('#contactform').serialize(),function(data){ if(data.error){ formmsg.append(data.error); }else{ formmsg.append("email received!"); } },"json"); });
when have error, error msgs appended correctly. if don't have error, not see else statement run through. why this?
Comments
Post a Comment