app/views/searchjoy/searches/stream.html.erb in searchjoy-0.4.0 vs app/views/searchjoy/searches/stream.html.erb in searchjoy-0.4.1

- old
+ new

@@ -1,13 +1,23 @@ <h1>Live Stream</h1> <table id="stream"></table> <script> + function load(element, path) { + var request = new XMLHttpRequest(); + request.open("GET", path, true); + request.onload = function() { + if (request.status >= 200 && request.status < 400) { + var resp = request.responseText; + element.innerHTML = resp; + } + }; + request.send(); + } + function fetchRecentSearches() { - $("#stream").load("<%= searches_recent_path %>"); + load(document.getElementById("stream"), "<%= searches_recent_path %>") setTimeout(fetchRecentSearches, 5 * 1000); } - $( function() { - fetchRecentSearches(); - }); + fetchRecentSearches(); </script>