View Full Version : Simple Form Submission How?

01-05-2009, 01:35 AM
1) Script Title: Basic Ajax Routine

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

3) Describe problem:


I'm trying to get this simple form below to submit via the post method so the response loads in the div shown without a page refresh. The form works just fine on it's own but it doesn't seem to be interacting properly with the script because it's not doing what it's supposed to do; no errors, just doesn't load the response in the div named postresult.

I've searched for a straightforward example of posting a simple form via this script and have the result in a div but cannot find any examples.

It seems that my skills aren't good enough to figure this out by myself so I'm posting here in the hope that someone can point out what I'm doing wrong.

I have the script properly installed and the page pointed to it.


<div id="postresult">

<form id='contact_form' method="post" action="http://website.com/index.php" onsubmit="var poststr=createpoststring(); ajaxpack.postAjaxRequest('http://isawyou.com/view', poststr, processGetPost, 'txt'); return false" >

<div class='hiddenFields'>
<input type="hidden" name="XID" value="1285be6b71dbf6bd731019230c60a95837ba219b" />
<input type="hidden" name="ACT" value="20" />
<input type="hidden" name="RET" value="" />
<input type="hidden" name="URI" value="/message/tab_connect/1438/" />
<input type="hidden" name="recipients" value="cGV0ZXJAaXNhd3lvdS5jb20=" />
<input type="hidden" name="user_recipients" value="n" />
<input type="hidden" name="charset" value="utf-8" />
<input type="hidden" name="redirect" value="" />
<input type="hidden" name="replyto" value="" />
<input type="hidden" name="site_id" value="1" />

<p><strong>Your email:</strong><br />
<input type="text" id="from" name="from" size="40" maxlength="35" value="me@domain.com" /></p>

<p><strong>Email Subject:</strong><br />
<input type="text" id="subject" name="subject" size="40" maxlength="35" value="" /></p>

<p><strong>Message:</strong><br />
<textarea id="message" name="message" rows="5" cols="40"></textarea></p>

<p><input type="text" class="textinput_full" name="captcha" value="" maxlength="24" /><br />
<span class="txt_1">Enter the word/letters you see in the image above (cASe insensITiVe)</span></p>

<p><input type="submit" name="submitButtonName" value="Send" /></p>


</div><!-- POST RESULT -->

<script type="text/javascript">

function processGetPost(){
var myajax=ajaxpack.ajaxobj
var myfiletype=ajaxpack.filetype
if (myajax.readyState == 4){ //if request of file completed
if (myajax.status==200 || window.location.href.indexOf("http")==-1){ //if request was successful or running script locally
if (myfiletype=="txt")
alert("The following error has occured "+myajax.responseText)


01-05-2009, 08:48 PM
I'm completely puzzeled as to why I can't get the code in my previous post to work. I'd appreciate ANY suggestions or input!!!


01-06-2009, 05:52 PM
I must have bad breath.