I have no experiece with the library you are using; however, i do have experience in native JavaScript. Hopefully, someone with experience with this library can expand my answer to further any information you may need to achieve your goals.
What you are trying to achieve is very easy but you need to first understand how asynchronous functions work.
asynchronous functions(async)
- May be invoked on another thread (for thread-based deferral
mechanisms), so apps must synchronize any resources the callback
accesses.
- Cannot touch anything tied to the original stack or thread, such as
local variables or thread-local data.
- If the original thread held locks, the callback will be invoked
outside them.
- Must assume that other threads or events could have modified the
application’s state.
That said, you have 2 choices that come to mind. call the asynchronous functions using a latter method or check if each function has run successfully using a timeout.
I suggest using a latter.
(new DevExpress.data.DataSource({
store: Deneme.db.deneme
}).load().done(function (result) {
alert("1x");
(new DevExpress.data.DataSource({
store: Deneme.db.deneme1
}).load().done(function (result) {
alert("2x");
(new DevExpress.data.DataSource({
store: Deneme.db.deneme3
}).load().done(function (result) {
alert("3x");
}));
}));
}));
using the timeout, you should know that the timeout uses an asynchronous function as well.
var returns = array(false, false, false);
var denemeSource = new DevExpress.data.DataSource({
store: Deneme.db.deneme
}).load().done(function (result) {
returns[0] = true;
});
var denemeSource1 = new DevExpress.data.DataSource({
store: Deneme.db.deneme1
}).load().done(function (result) {
returns[1] = true;
});
var denemeSource2 = new DevExpress.data.DataSource({
store: Deneme.db.deneme2
}).load().done(function (result) {
returns[2] = true;
});
timeout(function(){
//all functions run successfully
});
function timeout(success_func) {
setTimeout(function () {
for(var k in results){
if(results[k] == false){
has_false = true;
break;
}
}
if(has_false)
timeout();
else
success_func();
}, 1000);
}