Javascript error; Uncaught SyntaxError: missing ) after argument list

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)

Answers:

Answer

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

myFunction('162.223.8.210', '25567', '#factionsOnline');

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.