Welcome to WebmasterWorld Guest from 23.20.147.6

Forum Moderators: open

Message Too Old, No Replies

Ajax.Request (Scriptaculous Framework)

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

Junior Member

10+ Year Member

joined:Feb 14, 2007
posts:92
votes: 0


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>';}?>
</div>

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)

Junior Member

5+ Year Member

joined:July 26, 2007
posts:76
votes: 0



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)

Junior Member

5+ Year Member

joined:July 26, 2007
posts:76
votes: 0


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)

Junior Member

10+ Year Member

joined:Feb 14, 2007
posts:92
votes: 0


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)

Junior Member

10+ Year Member

joined:Feb 14, 2007
posts:92
votes: 0


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

Junior Member

10+ Year Member

joined:Feb 14, 2007
posts:92
votes: 0


RESOLVED

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