Ankur
Ankur

Reputation: 51100

Javascript function call causes error

I am trying to call a function "makeQuery" and it's not working, FireBug is telling me:

missing ; before statement
[Break on this error] makeQuery(this.id){\n

I don't quite understand where it wants me to put the ";"

$(".predicate").click(function () {
    makeQuery(this.id){
    alert(this.id);
    }
});

function makeQuery(value){
    queryString = queryString+"val="+value+"&";
    variables = variables+1;
    alert(queryString);
    alert(variables);           
}

Upvotes: 1

Views: 134

Answers (2)

Kelsey
Kelsey

Reputation: 47726

You have an extra curly brackets at wrapping the alert which doesn't make sense:

makeQuery(this.id){\

Should be:

$(".predicate").click(function () { 
    makeQuery(this.id);
    alert(this.id);      
}); 

The makeQuery requires the ; since you are calling a function.

Upvotes: 0

Ben Rowe
Ben Rowe

Reputation: 28711

replace

makeQuery(this.id){
alert(this.id);
}

with

makeQuery(this.id);
alert(this.id);

Upvotes: 3

Related Questions