Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #31573

AJAX forms

Newsgroups comp.lang.javascript
Date 2016-10-14 13:15 -0700
Message-ID <853ac26d-01db-49dd-9d77-62f49b7fcaae@googlegroups.com> (permalink)
Subject AJAX forms
From bit-naughty@hotmail.com

Show all headers | View raw


If I have a form where people write stuff and post it (a forum, say) - when they click "Post", I want the form to disappear, and a "Message posted" or whatever text to appear, via AJAX.... - my question is, after the message has been posted, ie. the server side replies with an "OK" or whatever, how do I get rid of the form on the page and replace it with the "Message posted" text? Is it removeChild? I assume this would work....?: x.parentNode.replaceChild(document.createTextNode("Message Posted"), n) ;  


But I also saw this sample code in my book (for showing how this sort of stuff is done, not specifically for MY case):

var b = document.createElement("b");
parent.replaceChild(b, n);   // Replace node n with the <b> element
b.appendChild(n); // Make n a child of the <b> element

I'm not understanding what the "appendChild" is for - surely replaceChild by itself will put in the Bold element? Why is the appendChild needed after that?

Thanks.

Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

AJAX forms bit-naughty@hotmail.com - 2016-10-14 13:15 -0700
  Re: AJAX forms Tim Streater <timstreater@greenbee.net> - 2016-10-14 21:42 +0100
  Re: AJAX forms bit-naughty@hotmail.com - 2016-10-19 06:43 -0700
    Re: AJAX forms Tim Streater <timstreater@greenbee.net> - 2016-10-19 15:07 +0100
  AJAX forms Ram Tobolski <ramtob@gmail.com> - 2016-10-20 10:20 -0700
    Re: AJAX forms JJ <jj4public@vfemail.net> - 2016-10-21 20:37 +0700

csiph-web