I have created a button. When I click the button, I want it to run a PHP file and display alert. Here's what I'm trying:
HTML:

```
<button id="testid" style="height:20px; width: 50px; cursor: pointer" onclick="logoutfunc()">Logout</button>

```

**JavaScript:**

```
function logoutfunc() {
    $(document).ready(function() {
        $("#testid").click(function() {
            $.ajax({
                url: 'logoutt.php',
                type: 'post',
                success: function(result11) {
                    //$(location).attr('href', 'login.php');
                    alert(result11);
                },
                error: function() {
                    alert("no");
                }
            });
        });
    });
}

```

**logoutt.php**

```
<?php
$a="Hello";
echo $a;
?>

```

Now the problem is that when I click the button first time, it doesn't display the alert. But when I click it again, it displays same alert twice. And when I click it again, it alerts 3 times and so on. What wrong have I written?