View Full Version : enter activate function

Phil Jackson
09-21-2009, 11:22 AM
Hello all i have the following:

$("#getInfo").bind("click", function(){
var keyword = $("#keyword").val();
$("#content").html('Gathering data... <img src="loader.gif" />');
type: "GET",
data: 'keyword=' + keyword,
url: 'proccess.php',
cache: false,
error: function(html){
"<span class=\"red\">Error: Network connection low, please try again later.</span>" + html
setTimeout(ready, 500000);

When a button is clicked, away it goes. But if you type info in the input box, and press enter, obviously nothing happens. how do i activate function when data is inserted and then enter is pressed?

Phil Jackson
09-21-2009, 02:24 PM
no? nobody?

09-21-2009, 05:20 PM
$("#keyword").keyup(function(e) {
if(e.keyCode == 13) {

// do stuff

//and stop Enter submitting the form
return false;