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? Quote Link to comment 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; } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.