TheEddy Posted August 3, 2010 Share Posted August 3, 2010 I want to submit a form using ajax so that the page doesn't have to reload. How do I do this? Link to comment https://forums.phpfreaks.com/topic/209716-submit-a-form-using-ajax/ Share on other sites More sharing options...
radar Posted August 3, 2010 Share Posted August 3, 2010 since you are using prototype i would do an onclick on the submit button... and then write your function in JS like this function submitit(formID) { var url = "formsubmit.php"; var pars= Form.serialize(formID); $('TransMsgDisplay').innerHTML='<img src="../templates/admin/img/indicator.gif" align="center">'; var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete: processGetLogin }); } function processGetLogin(originalRequest) { var responseTextTrim=trim(originalRequest.responseText); if(responseTextTrim == 1) { window.location.href="index.php"; } else { $('TransMsgDisplay').innerHTML=responseTextTrim; } } Link to comment https://forums.phpfreaks.com/topic/209716-submit-a-form-using-ajax/#findComment-1094798 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.