javascript - Call a method when another one finishes -
i have function in javascript consists of ajax call. let's call search();
then have event onkeyup.
in onkeyup event, have enterpressed() function.
i want call function after search() finishes.
i think callbacks won't here.
here's code:
function search () { ... } ed.onkeyup.add(function (ed, e) { if (e.keycode == 13) enterpressed(); } function enterpressed() { ... }
callbacks way forward.
either:
- bind keyup event handler in callback fires when search finishes or
- set variable (in scope both functions) , change value when search finishes. before doing in keyup handler, check value and, if hasn't changed,
return
immediately.
(this assumes calling of enterpressed
keyup function significant. if including of keyup code red herring shows want call @ other time as well then use callback directly).
Comments
Post a Comment