In AJAX, why onreadystate = function () should be written in front of open and send

readyState is 0 when generating xmlHttp, and changes when XMLHttpRequest.open, oepn will trigger onreadystatechange event.
The oepn is placed before onreadystatechange, and the onreadystatechange event is executed once less than after onreadystatechange.
The readyState property holds the state information of the server response. Whenever readyState changes, the onreadystatechange function will be executed.
Put it in the back, it will be executed once less

Published 24 original articles · praised 4 · visits 2038

Guess you like

Origin blog.csdn.net/weixin_44226263/article/details/103016186