Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,547
    Thanks
    57
    Thanked 148 Times in 147 Posts

    enter activate function

    Hello all i have the following:

    Code:
    $(document).ready(function(){
    	$("#getInfo").bind("click", function(){
    		var keyword = $("#keyword").val();
    		$("#content").html('Gathering data... <img src="loader.gif" />'); 
    		$.ajax({
    			type: "GET", 
    			data: 'keyword=' + keyword, 
    			url: 'proccess.php', 
    			cache: false,  
    			error: function(html){
    				$("#content").html(
    				"<span class=\"red\">Error: Network connection low, please try again later.</span>" + html
    			);},  
    			success: 
    			function(html){
    				$("#content").html(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?

  • #2
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,547
    Thanks
    57
    Thanked 148 Times in 147 Posts
    no? nobody?
    Website Design Mansfield
    PHP Code:
    function I_LOVE(){function b(&$b='P'){$b.='P';}function a($_){return $_++;}$b='P';define("B",'H');b($b=implode('',array($b=a($b),$b=a(B))));b($b);return $b;}
    echo 
    I_LOVE(); 

  • #3
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Code:
    $("#keyword").keyup(function(e) {
    	if(e.keyCode == 13) {
    
    		// do stuff
    
    
    		//and stop Enter submitting the form
    		e.preventDefault();
    		return false;
    	}
    });


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •