Skip to content

Commit 99a74e1

Browse files
author
SimonSteinberger
committed
1 parent c92f1a6 commit 99a74e1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

demo.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,12 @@ <h4>Optimizing AJAX requests</h4>
189189
To further reduce server impact, it's possible to abort unfinished AJAX requests before starting new ones.
190190
Again using jQuery's AJAX method for brevity:
191191
</p>
192-
<pre class="prettyprint"><code>new autoComplete({
192+
<pre class="prettyprint"><code>var xhr;
193+
new autoComplete({
193194
selector: 'input[name=&quot;q&quot;]',
194195
source: function(term, response){
195196
try { xhr.abort(); } catch(e){}
196-
var xhr = $.getJSON('/some/ajax/url/', { q: term }, function(data){ response(data); });
197+
xhr = $.getJSON('/some/ajax/url/', { q: term }, function(data){ response(data); });
197198
}
198199
});</code></pre>
199200
<p>

0 commit comments

Comments
 (0)