JS/AJAX Auto submit form: Disabling enter key to prevent page refresh
<p>I am using a function that will submit with ajax and without the help of a button click. But I am currently undergoing two issues which with trial and error haven't found plausible solutions: </p>

<p>First is there any way I can disable the enter button click(this causes the whole page to refresh)?</p>

<p><a href="http://jsfiddle.net/pXA6U/3/" rel="nofollow">JSFIDDLE</a> basic example in how the JS function works</p>

<p>Second, It feels like I am going the roundabout way to display what has been posted. How can I change this part of the function <code>$('#special').html('&lt;p&gt;' +  $('#resultval', result).html() + '&lt;/p&gt;');</code> to have it POST just inside a div called <code>#special</code> without the need of <code>span or &lt;p&gt; #resultval</code>?</p>

<p>Everytime i echo through php I have to do set it like this to display a result: <code>&lt;div id="special"&gt;&lt;span id="resultval"&gt;This is the result.&lt;/span&gt;&lt;/div&gt;</code></p>

<pre><code>&lt;script&gt;
    $(document).ready(function() {
     var timer = null; 
     var dataString;   
     function submitForm(){
       $.ajax({ type: "POST",
                url: "posting.php",
                data: dataString,
                success: function(result){

                   $('#special').html('&lt;p&gt;' +  $('#resultval', result).html() + '&lt;/p&gt;');

                }

       });
       return false;
     }
     $('#ytinput').on('keyup', function() {
        clearTimeout(timer);
        timer = setTimeout(submitForm, 050);
        var name = $("#ytinput").val();
        dataString = 'name='+ name;
     });
     }); 

&lt;/script&gt;
</code></pre>
