View Full Version : Loading a Form with Ajax

03-01-2007, 08:13 PM
1) Script Title: Dynamic Ajax Content

2) Script URL (on DD): http://dynamicdrive.com/dynamicindex17/ajaxcontent.htm

3) Describe problem:

I have a form on my website that loads on an ajax loaded page. I want to be able to submit my form in that same ajax square. I tried putting the following code in there but it would not work.

<form action="javascript:ajaxpage('../mypage.php?id=785545678', 'ajaxBox')" method="post">
When you click the submit button, nothing happens. Does anyone know how to do this?

03-02-2007, 03:16 AM
Not sure if this will work or not, but instead of using the action attribute, try using the onsubmit attribute. This will look like the following:

<form method="post" onsubmit="ajaxpage('../mypage.php?id=785545678', 'ajaxBox');">

Hope this helps.

03-02-2007, 01:45 PM
So I tried this and the form submitted, however it submitted to the entire page, and the page reloaded. I'm assuming this is because I have no "action" tag, and I believe the default "action" is the current page that you are on. :(

03-07-2007, 01:18 AM
alright, so I found a solution for this problem outside of DynamicDrive and it works great! In case anyone would like to see: