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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.