10

I keep getting this error (Javascript error; Uncaught SyntaxError: missing ) after argument list) when trying to call a simple function. Everything works without calling it in a function but I need to do it multiple times.

function myFunction(ip, port, div) {
    $.get('http://mcping.net/api/'+ ip + ":" + port, function(data){
        console.log(data.online);
        $(div).html(data.online);
    });
}
myFunction(162.223.8.210, 25567, #factionsOnline)
0

1 Answer 1

11

You're missing a parentheses because you didn't quote your strings

myFunction('162.223.8.210', '25567', '#factionsOnline');
Sign up to request clarification or add additional context in comments.

4 Comments

oh, thought because they were numbers, they wouldn't need it?
The numbers stricly don't but you're joining them with strings anyway, but the last argument isn't a number
Also 162.223.8.210 is not a valid number, so that needs to be quoted
alright, thanks. Also what is better to use single quotes or double quotes?

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.