我感到羞耻的是,不能理解为什么所有的 j言都是不义的,
例如,我们已经呼吁这样的秩序。
电话:1
电话:
如果职能2取决于职能1的结果,但不能确保,因为执行是同步的。 情况如何? 为什么?
如果确实如此,如何确保它们是同步的。
If this is duplicated question, I am sorry, because it is quiet new for me.
我首先感谢你的回答。
我感到羞耻的是,不能理解为什么所有的 j言都是不义的,
例如,我们已经呼吁这样的秩序。
电话:1
电话:
如果职能2取决于职能1的结果,但不能确保,因为执行是同步的。 情况如何? 为什么?
如果确实如此,如何确保它们是同步的。
If this is duplicated question, I am sorry, because it is quiet new for me.
我首先感谢你的回答。
贾瓦文大声呼声。 如果第二项职能取决于第一项职能的结果,则你可以采用反馈模式。
function foo(callback) {
var results = // get some results;
callback(results);
}
function boo(results) {
// do something with results here..
}
foo(boo);
无国界记者协会的职能是保证秩序,其行为与其他语言一样。 例如:
function f1() {
alert(1);
}
function f2() {
alert(2);
}
f1();
f2();
页: 1 更有甚者,AFAIK javascript在一只read子上,就不必担心种族条件。
j脚石的 as脏部分来自等待事件。 例如,如果你提出2项“jax”要求(在一神中,一心一意孤独,你不能首先保证,因此,如果你对这两项请求有不同的呼吁,你可以首先保证。
将两个职能连起来肯定不是同步的。
In fact.. javascript is 100% synchronous. Unless you use web workers all javascript will always run in a single thread, in a single process. There is never, ever a situation where 2 scripts are running at the same time.
Even if you handle an event, coming from an XMLHTTPRequest for instance, the event will only be triggered after all other javascript code has stopped executing.
正如对你问题的评论中提到的, Java语功能电话通常不是同步的。 为了:
function sayHello() {
console.log("Hi");
}
function sayBye() {
console.log("Bye");
}
sayHello();
sayBye();
上述代码将首先印成“Hi”,然后是“Bye”,因为电话sayHello
和sayBye
按此顺序排列。
但是,如果一项职能不时地采取某些行动,而你又履行另一项职能,依靠这一结果,你可以提供第二项职能,作为对不同步要求的回应。 例如:
xmlHttpRequestObj.onreadystatechange = function() {
if(xmlHttpRequestObj.readyState == 4 && xmlHttpRequestObj.status == 200) {
//Asynchronous call returned successfully. Do something that relies on that here.
}
}
我不知道你怎么说“Javascript被普遍说是 as的”。 总体情况正好相反: Java字几乎总是而不是。
因此,一般而言(无背风、无休止、无事件处理),下列职能称为 依次执行。
function1();
function2();
如果你将这两项职能分配给一次活动,这两项职能将同时称为,但不会在parall执行。 如果在setout <>code>)上或作为Ajax背书上都注明了两者。 见。 ...... Java经典保证单一阅读吗?
你本可以听说Ajax是不合时宜的。 如果你认为向服务器提出的请求与用户不相干扰,“在背景中”。 但是,这并不意味着 Java文是 as。 事实上,即使有Ajax电话,javascript 部分也只读过。
How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.
I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...
Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...
Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...
I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...
Is it possible for someone to give me a few pointers on how to display a multidimensional array in the form of a bar graph? The array is multidimensional, with three elements in each part - and the ...
Is it possible to reload a form after file-input change? I have a form where the user can chose an image for upload. I also have a php script which displays that image resized. I only wonder if it ...
I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.