0

trying to do some low-level ajax that hits url in the background but does nothing on the client side. Here is the code:

can_id = $(this).attr('id');            
$.ajax({
    url:"savethis.php",
    data:"q=0&can_id="+can_id;
});

but I keep getting this error:

Uncaught SyntaxError: Unexpected token ;

When I comment out the ajax() portion the error goes away. Why am I getting this error?

2
  • 2
    The error is telling you what the problem is. There is a ; where there isn't supposed to be. So remove the ; after can_id... Commented Nov 19, 2011 at 1:49
  • bah, thanks. Staring at the screen too long Commented Nov 19, 2011 at 1:51

1 Answer 1

2

You have a semicolon at the end of can_id. Remove it

data:"q=0&can_id="+can_id**;**
Sign up to request clarification or add additional context in comments.

1 Comment

I agree. Complement: semicolon is used as separator for statements in javascript. Hence, @themerlinproject should use it only ending a statement, declaring a function or a variable and stuff, NOT declaring parameters inside a function call :)

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.