Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #25721
| From | Joao Rodrigues <groups_jr-1@yahoo.com.br> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: callback function?! what is it?!? |
| Date | 2014-08-21 18:39 -0300 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <lt5ov6$es8$1@speranza.aioe.org> (permalink) |
| References | <e14ddd81-4ac6-4851-a6db-714238d411ce@googlegroups.com> |
On 21/08/2014 11:22, Andrea wrote:
> Hallo!
> In line 121 at code in
> https://github.com/brianreavis/selectize.js/blob/master/examples/cities.html
>
> there is a function called "calback"
> I can not see where it is defined. What is it? is it a javascript function?
> is it a Jquery function?
> what does it do?
>
> Thank you in advance for te time you'll spend for answering me
> Andrea
>
> P.S. following there is part of the code:
>
> $select_state = $('#select-state').selectize({
> onChange: function(value) {
> if (!value.length) return;
> select_city.disable();
> select_city.clearOptions();
> select_city.load(function(callback) {
> xhr && xhr.abort();
> xhr = $.ajax({
> url: 'http://www.....te_of/' + value + '.json',
> success: function(results) {
> select_city.enable();
> callback(results);
> },
> error: function() {
> callback();
> }
> })
> });
> }
> });
>
A callback function, or simply a "callback", is a function passed as a
parameter to other functions, in order to execute specific tasks and /
or after certain I/O operations
E.g.
function doSomething(callback) {
var results;
// compute some results
if (typeof callback == "function") {
callback(results);
}
}
function write2Server(file) {
// this will be called back in doSomething().
}
doSomething(write2Server);
--
Joao Rodrigues
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
callback function?! what is it?!? Andrea <andrea.lorizzo@gmail.com> - 2014-08-21 07:22 -0700 Re: callback function?! what is it?!? Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-08-21 18:39 -0300
csiph-web