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();
		docFrag.appendChild(scriptElm);
		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!
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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.