How to clear html input related with php and ajax?
<p>How can I set automatically clear my html input after click <code>enter</code>? It's complicated because my program uses ajax and php also. I tried to do this by jQuery <code>$("#txt").val('')</code> but then my input is clearing every single typed letter (I need to clear input only after click <code>enter</code>).   </p>

<pre><code>&lt;html&gt;
&lt;body&gt;
&lt;div&gt;&lt;label for="txt"&gt;Text:
&lt;input id="txt" name="txt" type="text" value="" size="20"&gt;&lt;/label&gt;&lt;/div&gt;

&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"&gt;
&lt;/script&gt;

&lt;script&gt;
   $(window).load(function() {
       $("#txt").keyup(function(event) {
           if (event.keyCode == 13) 
            $.ajax({
                url: 'hello.php',
                data: {
                    func: 'test',
                    txtVal: $("#txt").val()
                },
                type: 'post',                                   
                });
              $("#txt").val('')
           });
    });
&lt;/script&gt;
</code></pre>