I have already asked a question but I wanted to ask it in another way with another question. Is that possible call a method 10 times in asynchronous mode without specifying a return value. I am doing everything in a single page. I do not need to visit any other page. I have got a set of operation, each operation should wait for the previous one.
like this:
开发者_如何学JAVA$.get('myhtmlpage.html', function(){
myCallBack(param1, param2);
});
or like this:
function translate(i) {
google.language.translate(testua, languages[i], languages[i+1], function(result) {
if (result.translation) {
text = result.translation;
f.textarea1.value = text;
if (i < translationNumber) { translate(i++); }
}
}
}
I believe these are telling me something but I need to see a sample..
http://api.jquery.com/jQuery.ajax/
http://docs.jquery.com/How_jQuery_Works#Callback_and_Functionsor suggest me sth please.
A sample code would be great!
thanks.. regards..
I think you may be misunderstanding how JavaScript works. In JavaScript you only have one thread, which means that you can't call any functions asynchronously execpt when you do AJAX-style calls.
The short answer is, you can't call methods asynchronously.
精彩评论