if (http2.readyState != null && (http2.readyState == 4 || http2.readyState == "complete")) { if (http2.status == 200 || http2.status == 304 || http2.status == 0) { foo(); } }