7

This javascript produces an error:

missing ) after argument list

In firebug with the code:

<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>

What am I doing wrong?

4 Answers 4

9

function d misses an opening bracket, {

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

Sign up to request clarification or add additional context in comments.

2 Comments

I knew it was something simple, Im just too noob:) Thanks for your help!
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.
4

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();
    });
}

Comments

2

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>

Comments

2
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()
       });
};

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.