Hi all!
I am trying to make use of JDOMP but apparently something does not work.
Here is my code:

function saveTextToServer(){
		var dateNow = new Date();
		var time = dateNow.getTime();
		var url = "saveNotewall.php?text=";
		var noteField = document.getElementById("noteField");
		url = url + noteField.value + "&time=" + time;
		var scriptElm = document.createElement("script");
		scriptElm.setAttribute("type", "text/javascript");
		scriptElm.setAttribute("language", "JavaScript");
		scriptElm.setAttribute("src", url);
		var toServer = document.getElementById("toServer");
		var varToServer = document.getElementById("varToServer");
		var newVar = document.createElement("div");
		var docFrag = document.createDocumentFragment();
		newVar.setAttribute("id", "varToServer");
		newVar.appendChild("docFrag");//this row seems to be the problem
		toServer.replaceChild(newVar, varToServer);

I have marked out the row that seems to give me a problem.
It seems as if the code stops to parse at this row, what is my problem?

Many thanks in advance!

8 Years
Discussion Span
Last Post by marcux

appendChild requires a DOM element, not a string. The Firefox error console would have pointed out the problem much earlier. Other than that, using elem.setXXX / elem.getXXX rather than elem.XXX = YYY might cause failures in some browsers.


Thank you!
Sometimes you get blind by staring at your code.
Of cause, appendChild should not have the string as an argument.
So using var.setXXX gives you problems in some browsers?
Preferably is to use var.xxx = value!
Thanks alot for the tip!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.