Page 1 of 1

"missing ) after argument list"

Posted: Thu May 20, 2010 10:51 am
by JKM
ajax.js:

Code: Select all

var $j = jQuery.noConflict();

function fadeS() {
	$j("div.fader").fadeOut(999);
}

function fadeC(text) {
	document.getElementById("tips").innerHTML = '<div class="fader">'+text+'</div>';
	$j("div.fader").hide();
	$j("div.fader").fadeIn(999);
}

function sswitch(text) {
	var xmlHttp;
	try {
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {
				alert("Nettleseren din støtter ikke AJAX!");
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			fadeS();
			setTimeout("fadeC('"+xmlHttp.responseText+"')", 999);
		}
	}
	xmlHttp.open("GET","misc/tips_handle.php?w=detalj&id="+text,true);
	xmlHttp.send(null);
}
tips_handle.php:

Code: Select all

<?php

	echo '<a href="#" onClick="javascript:sswitch(\'blabla\');" />';

?>
Error message:
"missing ) after argument list"
It seems like I'm getting this error message when the response contains "('something')". So I'm wondering how I can fix this.

Thanks for any help!

Re: "missing ) after argument list"

Posted: Thu May 20, 2010 10:59 am
by mikosiko
function sswitch(text)

.....

echo '<a href="#" onClick="javascript&#058;switch(\'blabla\');" />';

typo ?

Re: "missing ) after argument list"

Posted: Thu May 20, 2010 11:01 am
by JKM
oops, yeah. But still, the same error message occurs.

Re: "missing ) after argument list"

Posted: Thu May 20, 2010 11:20 am
by kaszu
Looks good, maybe in xmlHttp.responseText are single quotes? To be safe replace

Code: Select all

setTimeout("fadeC('"+xmlHttp.responseText+"')", 999);
with

Code: Select all

setTimeout(function () {
    fadeC(xmlHttp.responseText);
}, 999);

Re: "missing ) after argument list"

Posted: Fri May 21, 2010 6:22 am
by JKM
Thanks a lot!