Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Ajax.Request (Scriptaculous Framework)

4:50 pm on Aug 15, 2007 (gmt 0)

5+ Year Member

Experimenting with Ajax a little, I'm posting a form which was previously posted with your regular html, php on the page then processed the input and returned an error message or a success message.

Ofcourse, this message was only displayed with a page refresh, ie;

<div id="returnMessage">
<?php if($error){ echo '<h4>Error-'.$error.'</h4>';}?>

I've put a new ajax request in my form tag, onsubmit, which I can see with firebug is posting all of my form data correctly

onsubmit="new Ajax.Request('widgetsets.php',{asynchronous:true,parameters:Form.serialize(this)}); return false;"

I would essentially like the div "returnMessage" to update once a post has been processed, without reloading the rest of the page.

Is this possible?

I've been playing around with it for a while, trying things such as
onComplete:$('returnMessage').update('<?php echo $error;?>')

3:14 am on Aug 16, 2007 (gmt 0)

5+ Year Member

onsubmit="new Ajax.Request('widgetsets.php',{asynchronous:true,parameters:Form.serialize(this)}); return false;"

Did you try this

onsubmit="new Ajax.Updater('widgetsets.php',{asynchronous:true,parameters:Form.serialize(this)}); return false;"

3:15 am on Aug 16, 2007 (gmt 0)

5+ Year Member

correct one!

onsubmit="new Ajax.Updater(returnMessage,'widgetsets.php',{asynchronous:true,parameters:Form.serialize(this)}); return false;"

8:02 am on Aug 16, 2007 (gmt 0)

5+ Year Member

I did but CRAZY things were happening

for example, a page refresh was happening,

also, a duplicate of the entire page appears within the 'returnMessage' div.

On the plus side, this dupe does display the correct status message haha!

8:08 am on Aug 16, 2007 (gmt 0)

5+ Year Member

actually now it's just a page refresh thats happening, status returns correctly ofcourse
3:53 pm on Aug 16, 2007 (gmt 0)

5+ Year Member


I was actioning the page which on which the form resided - by habit have always put form processing php on the same page as the form

hence the whole page was loading into the specified div..


Featured Threads

Hot Threads This Week

Hot Threads This Month