The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

problems with textarea once text is edited

HI,

This question involves AJAX but this is not an ajax problem as the ajax works...this is a DOM related question. IM sorry its such a long read but its the only was i could describe my problem

I have an ajax app that allows a user to select a message from a list and then edit it in a textarea to the right of the list. Once the user has finished editing the message they click a submit button some more ajax runs and the message is sent back to the server. A confirmation message is the printed in place of the edited text in the textarea.

Now all works fine up to a certain point....a user can click edit, the message is loaded in the textarea and the user can click submit and the edited message gets submitted to the server.

The problem however is here. If the user clicks edit, clicks in the textarea but doesnt edit any text and then presses submit everything is fine and the confirmation message is printed. However id the user edits the message and then presses submit there is no confirmation printed and the user cannot click any further buttons....the page has to be reloaded for the app to do anything else.....BUT the message has been edited....

so i dont think its an ajax problem, i think its more something to do with the DOM...has anyone ever encountered problems with textareas once they've been clicked in/text edited?

I cant work this out....ive debugged and debugged but cant find the problem....ive also googled it do death....heres my code. First the functions ( sendmessage() sends the text and showconfirmation() prints the conf...duh!) and then the related html....

Ok i'll give that a try....although i think the readystate is getting to four because i know the php script is working...it does update the text in the db.....so i doubt if the reponse is not being sent back....but ive not tried the avenue of alerting the server response

Right ive put a print in where it says alert('polo'); in the above code ( in the show confirmation function) and indeed i do get the confirmation back ( i get two empty alerts for readystates 1 and 2 and then the confirmation text back for three and four)

So i knew everything was working and it was, as i thought, a problem with getting the conf text in top the textarea i moved it outside...so the confirmation is shown in a p tag above the text area and guess what i get the confirmation!!!!

Now its still not 100&#37; because after the user has edited and presses submit and got confirmation you cant click on any of the edit buttons...well you can but the text isnt loaded in to the textarea......

Yay it works! Sorted it....id post the solutions but it was a real combination of things...i spent 1 hour and a half debugging it on the train this morning.

Ajax rocks....if you want to learn it i picked it up from a book called head first ajax......the book treats you like a kid, in that it tells you everything two or three times and gives you loads of big images/diagrams with speech bubbles and stuff like that. Its a little grating at points but it really gets the message through.....id managed to achieve some effects ive been wanting to do after the first two chapters!