【问题标题】:How is xmlhttp.responseText assigned before xmlhttp.send()在 xmlhttp.send() 之前如何分配 xmlhttp.responseText
【发布时间】:2010-05-07 04:29:23
【问题描述】:

来自this example的新手ajax问题:
在 xmlhttp.open() 和 xmlhttp.send() 之前如何分配 xmlhttp.responseText ? (如果我们需要 demo_post.asp 中的数据)

我知道它在 onreadystatechange 中,但如果从上到下读取 javascript,我不明白。谢谢,放轻松!

【问题讨论】:

  • 我怀疑 .responstText 只是空的
  • @Dormilich:根据 Jack 的提示 - onready..() 的行为只是在这里定义的。它将在 sent() 或任何更改时调用。

标签: javascript html ajax events


【解决方案1】:

您需要研究闭包。

onreadystatechange 被分配了一个函数。该函数不会立即调用...查看它的名称。

【讨论】:

    猜你喜欢
    • 2011-03-27
    • 1970-01-01
    • 1970-01-01
    • 2017-05-02
    • 2018-02-27
    • 1970-01-01
    • 2011-08-16
    • 1970-01-01
    • 2020-07-02
    相关资源
    最近更新 更多