Permalink
Switch branches/tags
Nothing to show
Find file Copy path
ac9e39f Sep 20, 2011
Pascal Widdershoven Fixed example, fixes #2.
0 contributors

Users who have contributed to this file

39 lines (35 sloc) 1.12 KB
<!doctype html>
<html lang="en">
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript">
//just a quick example, in no way pretty code.
$(document).ready(function() {
$('form#search').submit(function() {
search($('input#query').val());
return false;
});
});
function search(query) {
//Try searching for 'Python', 'Hyde', 'Linux'.
var result = $.getJSON('http://8xh3a.api.indextank.com/v1/indexes/pwiddershoven_nl/search?q=' + encodeURIComponent(query) + '&fetch=title&snippet=text&callback=?', function(data) {
$('div#results').empty();
$.each(data.results, function(index, result) {
$('div#results').append('<div id="result">\
<p><a href="http://pwiddershoven.nl' + result.docid + '">' + result.title + '</a><br/>\
' + result.snippet_text + '</p>\
</div')
});
});
}
</script>
</head>
<body>
<form id="search">
<input type="text" id="query" name="query"/>
<input type="submit"/>
</form>
<div id="results">
</div>
</body>
</html>