JTallis Posted October 17, 2010 Share Posted October 17, 2010 I'm using Ajax to process a form. Code is below. It works fine, but what happens is.. the error is inside the table. So when I hide the previous form. If an error occurred, it'd populate the new div with the same kind of table, but with an error in. When processing the form again with this ... new div, it refreshes the page. So what I tried to do, is change the original forms HTML with the Ajax, and insert the HTML gotten from the validation (on form processing) but this never worked. It broke the whole script basically. $(function() { $("#resend").click(function() { $("#rsForm").hide(); $("#loading").show().html('<img src="http://www.kanawhavalleyre.com/images/loading_circle.gif" />'); $.ajax({ type: "POST", url: "modules/rsactivation/rsact.main.php", data: {email: $("#email").val()}, cache: false, success: function(html){ $("#loading").remove(); $("#msg").prepend(html); $("#msg").show(); } }); return false; }); }); rsact.main.php basically has the processing in it. It returns stuff where required. You can view what goes on [url=http://"http://www.horble.com/resendactivation.php"]Here. When clicking the button once, it looks fine, it works fine. Though when you click it again, it refreshes the page. #rsForm holds the original form that works, but #msg holds the new form given from rsact.main.php. As already noted, I tried to change the code to edit #rsForm and insert the output given from rsact.main.php but it never worked. Do you have any ideas? Thanks Quote Link to comment Share on other sites More sharing options...
JTallis Posted October 17, 2010 Author Share Posted October 17, 2010 Oops, sorry my bad. you can see here. CLICK ME Quote Link to comment Share on other sites More sharing options...
JTallis Posted October 17, 2010 Author Share Posted October 17, 2010 Sweet. I changed it around alot. #msg is now inside the form (#rsForm). It now works. This is the new Ajax. $(function() { $("#resend").click(function() { $("#rsForm").hide(); $("#loading").show().html('<img src="http://www.kanawhavalleyre.com/images/loading_circle.gif" />'); $.ajax({ type: "POST", url: "modules/rsactivation/rsact.main.php", data: {email: $("#email").val()}, cache: false, success: function(html){ $("#loading").hide(); $("#rsForm").show(); $("#msg").html(html); } }); return false; }); }); 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.