Post a form in jQuery when this form is loaded in AJAX with jQuery -
i want post form using jquery.post :
js function:
function post_ajax_form2(url,formid,message){ bsendmessage = 0; if (typeof message !== 'undefined') { bsendmessage = 1;} var data = jquery('#'+formid).serialize(); alert(data); jquery.post(url,data); if (bsendmessage == 1) { alert(message); } } the form loaded in ajax using single jquery.load.
html form loaded:
<form action="index.cfm" method="get" id="fdesc_preview"> <input type="hidden" name="change_preview" value="1"> <input type="checkbox" id="cbpreview" name="preview" class="preview" value="1" onclick="post_ajax_form2('myurl.html','fdesc_preview');" <cfif attributes.preview> checked</cfif>></td> <td>show short descriptions </td> </form> when click on checkbox form posted, data empty. same code on single html page work.
i'm missing ?
thanks responses.
with form of post:
jquery.post(url,data); if (bsendmessage == 1) { alert(message); } the if condition statement executes immediately, not waiting post return - post asynchronous , needs have if condition in callback function post.
example of change:
jquery.post(url,data).done(function(message) { alert(message); } });
Comments
Post a Comment