Go Back   WarriorForum - Internet Marketing Forums > Warrior Support Forums > Website Design
Register Blogs FAQ Social Groups CalendarHelp Desk

Reply
 
LinkBack Thread Tools
Old 10-12-2009, 12:29 PM   #1
Active Warrior
 
Join Date: May 2009
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default Form with AJAX

I use AJAX approach handling inputs from user. In my test code simplified from production code, there is a table with two cells. First cell has a form in it and the second cell has a button in it. OnClick is used to specify the javascript function. Every time when the button is clicked, a table of parts is shown 100%. When I click the Submit button, it just seems to executing the test code again. It doesn't even show the message I added for testing. I have to admit I don't know form much. I'm not very sure I coded the onclick() parameter the right way. I think the problem is in using the form the correct way. Can you help me to isolate the problem? Thanks,

The table code:
<table>
</tbody>
<tr>
<td>
<form method="post"
<p align="left"><input type="text" name="myPart"></p>
<input type="submit" value="Search" onclick="Doit($myPart)" />
</td>
<td>
<input type="image" src="image.jpg" alt="Part" onclick="Doit('HP')"/>
</td>
</tr>
</tbody>
</table>

The Javascript code is:
<script type="text/javascript">
var http = getHTTPObject();
function Doit(sId)
{
var url="getData.php?id="; // getData.php writes data back
http.open("GET", url+escape(sId), true);
http.onreadystatechange=handleHttpResponse;
http.send(null);
/*
for (i=0; i<10; i++)
document.write("Is it working?");
*/
}

function getHTTPObject()
{
........
}
function handleHttpResponse()
{
.......
}
</script>

Warren
WarrenW is offline   Reply With Quote
Old 10-13-2009, 11:10 AM   #2
Warrior Member
War Room Member
 
Join Date: Aug 2009
Posts: 9
Thanks: 12
Thanked 0 Times in 0 Posts
Default Re: Form with AJAX

Is the html code as shown below copied verbatim from your web page? If so, I can spot 3 errors straight away:
Code:
 
<table>
</tbody>
...
<form method="post"
...
</tbody>
</table>
1. The first </tbody> should be <tbody>
2. The '<form' tag is not closed (missing '>')
3. There is no end form tag '</form>'

At a quick glance, the Javascript looks ok, apart from:

Code:
 
var url="getData.php?id=";
Is there meant to be a variable after '?id=' e.g. '?id=sId' ?

If the above doesn't correct it, can you supply more detail?

Brian

www.AffiliateCashRadar.com. Get All ClickBank & PayDotCom Affiliate Products On One Convenient Easy To Use Website Free Every Day
brianoh is offline   Reply With Quote
Reply

  WarriorForum - Internet Marketing Forums > Warrior Support Forums > Website Design

Tags
ajax, form

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -6. The time now is 09:30 PM.