Please don't post so many times in a row. There is an 'edit' button at the bottom of your posts that you can use to update them if you think of something new to add.
Firstly, you don't want to create that massive function every time. It would be far preferable just to create a small function:
Code:
function myNewComm(what, mode, opt) {
var myNewAjax = createAjaxObj(),
url_myNew;
if (!myNewAjax) return false;
url_myNew = "processing/newComments" + what + ".php"
+ "?mode=" + mode
+ "&r=" + Math.random();
myNewAjax.open("GET", url_myNew);
myNewAjax.onreadystatechange = function() {
if (myNewAjax.readyState === 4 && myNewAjax.status === 200)
if (mode === "check")
if (myNewAjax.responseText.indexOf("no new comment") > -1)
return 0;
else return parseInt(myNewAjax.responseText);
else if (mode === "display")
displayMyNewComm(what, myNewAjax.responseText);
}
myNewAjax.send(null);
(opt ? setInterval : setTimeout)(function() { myNewComm(what, mode, opt); }, 15000);
}
Stylistically speaking, this function does far too much. You should break it down into several smaller functions. Also, I think that terming any of this 'AJAX' is rather misleading, since there doesn't appear to be any XML involved at all, and your function names are rather silly and quite uninformative.
Bookmarks