Javascript String Compare == sometimes fails

后端 未结 9 2039
你的背包
你的背包 2020-12-05 17:25

How could the following code sometimes evaluate to false?

(transport.responseText == \'1\' || 
 transport.responseText == \'CARD_VALID\')

M

9条回答
  •  北海茫月
    2020-12-05 18:02

    Try capturing the value of responseText into a different variable before entering that code block, in case the variable is updated somewhere in there.

    I don't have that much experience directly using XmlHttpRequest, but I do know that javascript has a number of places where it uses volatile references to interface objects that can change during execution, rather than a simple value.

提交回复
热议问题