Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #25717 > unrolled thread
| Started by | Andrea <andrea.lorizzo@gmail.com> |
|---|---|
| First post | 2014-08-21 07:22 -0700 |
| Last post | 2014-08-21 18:39 -0300 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.javascript
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
| From | Andrea <andrea.lorizzo@gmail.com> |
|---|---|
| Date | 2014-08-21 07:22 -0700 |
| Subject | callback function?! what is it?!? |
| Message-ID | <e14ddd81-4ac6-4851-a6db-714238d411ce@googlegroups.com> |
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();
}
})
});
}
});
[toc] | [next] | [standalone]
| From | Joao Rodrigues <groups_jr-1@yahoo.com.br> |
|---|---|
| Date | 2014-08-21 18:39 -0300 |
| Message-ID | <lt5ov6$es8$1@speranza.aioe.org> |
| In reply to | #25717 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web