views:

104

answers:

2

I have recently started upgrading my website to send and receive requests/response through ajax. I'm using the protoytpe library.

My exisiting html code contains certain img and input tags that aren't closed.

When i try to update the content of a element (say "div") with such html code by using the innerHTML property, i get parse errors such as "junk code" or "not well formed" etc.

Without using ajax, ie, without dynamic update of dom, the page is functioning normally even with the above html non-standard coding.

Is there Any way to use dynamic updating and still avoid hitting parse errors???

A: 

Yes, you can use dynamic updating if you make sure your page is standards compliant. JS libraries are designed with that in mind, and they have problems inserting data on non-standards compliant pages. You can probably fix the problem by simply closing the tags.

Scott M.
thanks.closing tags is just one example i gave, other errors include not well-formed errors pertaining to attribute suchas selected, disabled attributes.though ur solution is correct, but such errors are far too many (say 1000-2000) all over the existing web-pages, to go for manual editing, even certain html correction tools fail because these pages have inline webserver scripts which get edited too.so u got that clue?
i guess i got too far ahead of myself when i said "simply". If the html correction tools can fix at least some of the problems for you then youre already ahead of where you were. From what i can tell, it seems your problems arise when you try and insert the dynamic data, so perhaps you could concentrate your efforts in that area first.
Scott M.
@imdad: you could try inserting the simplest possible HTML such as a span tag with "Hello world" or something. See if that works. Perhaps its a particular tag in the HTML you are inserting that is causing the problem. Try and isolate that.
KarstenF
A: 

If you are using prototype.js, try using the "insert" and "update" methods.

http://www.prototypejs.org/api/element/insert

http://www.prototypejs.org/api/element/update