Jump to content

loading second page into <div id='content'> via ajax


telsiin

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/265584-loading-second-page-into-via-ajax/
Share on other sites

  • 4 months later...

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.