jQuery不提供您要查找的内容的回调。以下是可用的就绪状态:
Value State Description0 UNSENT open()has not been called yet.1 OPENED send()has not been called yet.2 HEADERS_RECEIVED send() has been called, and headers and status are available.3 LOADING Downloading; responseText holds partial data.4 DONE The operation is complete.
您正在寻找readystate 2,因为这是您最早知道服务器收到消息的事实。
这应该可以帮助您:
var xhr = new XMLHttpRequest();xhr.open("POST", clicked);xhr.onreadystatechange = function() { if (xhr.readyState >= 2) window.location = clicked;};xhr.send($('#track-click-post-url').attr('value'));https://developer.mozilla.org/zh-
CN/XMLHttpRequest进行进一步阅读。



