homepage Welcome to WebmasterWorld Guest from 23.20.149.27
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Ajax.Request (Scriptaculous Framework)
el_roboto




msg:3422993
 4:50 pm on Aug 15, 2007 (gmt 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;?>')

 

misterjonez




msg:3423411
 3:14 am on Aug 16, 2007 (gmt 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;"

misterjonez




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

correct one!

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

el_roboto




msg:3423548
 8:02 am on Aug 16, 2007 (gmt 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!

el_roboto




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

actually now it's just a page refresh thats happening, status returns correctly ofcourse

el_roboto




msg:3423914
 3:53 pm on Aug 16, 2007 (gmt 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..

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved