function test(url,username,password,jQuery,callback) { url = url || "/test.jsp"; jQuery.ajax({type:Get,url: url,async: true,password:password,username:username,complete:function(xmlhttp,status){ var ok = (200 <= xmlhttp.status && xmlhttp.status < 300) || xmlhttp.status == 1223; // status 204 -> 1223 in IE if (ok) { callback(true); } else { callback(false); } }}); var xmlhttp; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest() } else { xmlhttp = new ActiveXObject("MSXML2.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4) { var ok = (200 <= xmlhttp.status && xmlhttp.status < 300) || xmlhttp.status == 1223; // status 204 -> 1223 in IE if (ok) { callback(true); } else { callback(false); } } }; xmlhttp.open("Get",url,true,password); try { xmlhttp.send(null);//error } catch (e) { callback(null); } }