"missing ) after argument list"

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

"missing ) after argument list"

Post 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!
Last edited by JKM on Thu May 20, 2010 11:01 am, edited 1 time in total.
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: "missing ) after argument list"

Post by mikosiko »

function sswitch(text)

.....

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

typo ?
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

Re: "missing ) after argument list"

Post by JKM »

oops, yeah. But still, the same error message occurs.
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: "missing ) after argument list"

Post 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);
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

Re: "missing ) after argument list"

Post by JKM »

Thanks a lot!
Post Reply