$(document).ready(function() {
	$("#searchnow").on("click", searchGems)
});

function searchGems(e){
	e.preventDefault();
	var searchWord = $('#search').val()
	var ajaxSearch = $.ajax({
		url : '/search',
		type: 'POST',
		data: {name: searchWord},
		dataType: 'json'
	}).success(function(data) {
		//debugger
		//data
		for (var i = 0; i < data.length; i++) {
			$(".search-results").append(
				"<div class='panel-body text-primary'><strong><a href="+data[i].url+">"+data[i].name+"</a></strong><br></div>"
				)
		};
	})
}
@@ -65,16 +65,108 @@
 chGems)%0A
+%09//$(%22#search%22).keypress(function()%7Balert('hey')%7D)%0A%09$(%22#search%22).keypress(searchOnKeyPress)%0A
 %7D);%0A%0Afun
@@ -207,16 +207,36 @@
 ault();%0A
+%09console.log('cat')%0A
 %09var sea
@@ -529,21 +529,8 @@
 body
- text-primary
 '%3E%3Cs
@@ -543,16 +543,42 @@
 %3Ca href=
+'http://rubygems.org/gems/
 %22+data%5Bi
@@ -583,13 +583,15 @@
 %5Bi%5D.
-url
+name
 +%22
+'
 %3E%22+d
@@ -644,8 +644,506 @@
 %7D;%0A%09%7D)%0A%7D
+%0A%0A// on keypress%0A%0Afunction searchOnKeyPress()%7B%0A%09//e.preventDefault();%0A%09console.log('cat')%0A%09var searchLetter = $('#search').val()%0A%09var ajaxSearchLetter = $.ajax(%7B%0A%09%09url : '/search',%0A%09%09type: 'POST',%0A%09%09data: %7Bname: searchLetter%7D,%0A%09%09dataType: 'json'%0A%09%7D).success(function(data) %7B%0A%09%09//debugger%0A%09%09if (typeof data != %5B%5D)%7B%0A%09%09%09var gem = data%5B0%5D.name%0A%09%09%09$(%22.search-results%22).append(%0A%09%09%09%09%22%3Cdiv class='panel-body'%3E%3Cstrong%3E%3Ca href='http://rubygems.org/gems/%22+gem+%22'%3E%22+gem+%22%3C/a%3E%3C/strong%3E%3Cbr%3E%3C/div%3E%22%0A%09%09%09)%0A%09%09%7D%0A%09%7D)%0A%7D

Append search returns on keypress works