AJAX:简单的帖子不起作用

I recently asked a question about javascript and php together and I got pointed into the direction of ajax.

I did some learning, and now I'm trying to do something really simple.

<input type="text" id="txt">
<input type="button" onclick="functionPost();" value="test123">
<div id="result"></div>
<script type="text/javascript">
    function functionPost() {
        var input = ('#txt').value;

        $.post('search.php', {postname: input},
        function (data) {
            $('#result').html(data);
        });
    }
</script>

Basically, I get the value from the text input, I post it to the search.php page. If I echo something simple on this page, for example: echo "hello"; the whole thing works. My div shows "hello".

But if I try to use the $inputvalue = $_POST['postname']; on search.php, I get nothing at all, not even if I echo $inputvalue;.

I must be missing something small here.. I have no idea how ajax actually works, but I need this done.

Any ideas on why it won't get my posted value? I'm very inexperienced.

Thank you

Change var input = ('#txt').value to var input = $('#txt').val().