Reputation: 5
First of all, I'm trying to use an HTML element (button) to, onClick, perform a JavaScript function I have. The function is called Unban(player) which "unbans" a player from something I'm working on.
The element looks like this,
<button name="button" id="button" onclick="Unban('somebody')"/>
And the JavaScript looks like this:
function Unban(player){
if (confirm("Are you sure you want to remove the ban on " + player + "?")){
$.post("actions/unban.php",{Player:player},function(result){
if (result.contains("Error:"){
alert(result);
}
else{
alert("You have unbanned " + player + "!");
}
});
}
}
The problem is: Nothing happens at all when I call upon the Unban(player) function. I've done a bit of tests and it runs properly without the $.post, so it must be something related to it.
The PHP file works fine and is functional. It is also properly referenced in $.post.
Upvotes: 0
Views: 132
Reputation: 5108
There is a syntax error. A )
is missing here
if (result.contains("Error:")){
alert(result);
}
Upvotes: 3