telsiin Posted July 12, 2012 Share Posted July 12, 2012 I have a page the loads a form via ajax into <div id="content"> which works great however once the user submit the form I would like to load a different page/form into the <div id="content"> the PHP code I have trigger after the submit and user data is inserted to a table $insertGoTo = "registrybusiness.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } my problem is that the code above break out of the <div id="content"> refreshing the page I am looking for an alternative code that will load a new page called from the div id="content" and load it back in div id="content" $insertGoTo = "javascript:ajaxpage('registrybusiness.php', 'content');"; of course this doesn't work : P.S. my java script skill are the equivalently to a three year and theirs maybe better. Quote Link to comment Share on other sites More sharing options...
txmedic03 Posted November 21, 2012 Share Posted November 21, 2012 If you'll check out an ajax library like jQuery, they make it simple to make an ajax query like what you are asking for. You'll basically want to submit the form via ajax rather than a standard POST/GET method. If you prefer not to use a library there are lots of examples of form submission scripts that break down the steps to build the ajax function(s) required for what you want. If you prefer to avoid the libraries, but are having trouble locating a good tutorial on the matter, I could probably find a good one and give you a link. Just let me know which method you prefer and I'll try to point you in the right direction. Quote Link to comment Share on other sites More sharing options...
codefossa Posted November 21, 2012 Share Posted November 21, 2012 With jQuery it would just be $("#content").load("page.php"); 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.