jQuery .click event runs on page load
<p>I have this jQuery script in an external file. Im using it to update a database. I've been practicing around with it and cannot get it right. I would like for the .ajax call to be ran when my button (labeled with ID "add") is clicked, however the database is updated everytime the page is refreshed and NOT when the button is clicked! Can someone explain why? Thanks in advance</p>

<pre><code>$('#add').click(
    $.ajax({
        url: 'test.php',
        success: function() {
            alert("added");
        }
    })
);
</code></pre>

<p><strong>UPDATE</strong>:
Thanks to @flo I was able to get this working perfectly. Here's the final product:</p>

<pre><code>$(document).on('click','#add',function() {
    $.ajax({
        url: 'test.php',
        success: function() {
        alert("added");
        }
    })
});
</code></pre>
