views:

206

answers:

4

Hi all,

I have yet another JS issue ...grrr. Bear with me, I am a hopeless JS newbie.

I am receiving "missing ) after argument list" error in firebug with the code below:

<script type=\"text/javascript\">
function add( answer )
{   
$.post('../page.php?cmd=view&id=3523', {user_id: 3523, other_user_id: 2343}, function(d)
            $(answer).after(\"<span>Done!</span>\").remove();
        });
    }
}
</script>

Any help is always appreciated!

+2  A: 

Close post() function. third string from bottom should be ), not }.

EDIT: sorry, should be like this:

<script type=\"text/javascript\">
function add( answer )
{   
    $.post('../page.php?cmd=view&id=3523', {user_id: 3523, other_user_id: 2343}, function(d) {
        $(answer).after(\"<span>Done!</span>\").remove();
    });
}

Kuroki Kaze
+4  A: 

function d misses an opening bracket, {

$(answer).after( should not be escaped \", just a regular quote will do "

David Hedlund
I knew it was something simple, Im just too noob:) Thanks for your help!
Lea
since you're using firebug; when you encounter things like this, you can always paste the code into the firebug console and reproduce the error, and from there, if you don't find the syntax error, you can try and remove things, bit by bit, and see what removed line causes the error to go away.
David Hedlund
Wow!! thats an awesome tip.. I'll remember to do that!:) Thanks again!!
Lea
+1  A: 

Why are you escaping quotes? The problem is here :

$(answer).after(\"<span>Done!</span>\").remove();

change to

$(answer).after("<span>Done!</span>").remove();

or

$(answer).after('<span>Done!</span>').remove();

Also, you're missing a { after the post() function (probably you missed the right spot, since there's another in the wrong place), so the final output :

<script type=\"text/javascript\">
function add( answer )
{   
$.post('../page.php?cmd=view&id=3523', {user_id: 3523, other_user_id: 2343}, function(d) {
            $(answer).after("<span>Done!</span>").remove();
        });
}
</script>
yoda
+2  A: 
function add( answer )
{   
$.post('../page.php?cmd=view&id=3523', 
       {user_id: 3523, other_user_id: 2343}, 
       function(d){
         $(answer).after("<span>Done!</span>").remove()
       });
};
markmywords