All pastes #955962 Raw Edit

Miscellany

public javascript v1 · immutable
#955962 ·published 2008-03-24 23:04 UTC
rendered paste body
getId = function(filePath, params) {  if (window.XMLHttpRequest) {    var xmlhr = new XMLHttpRequest();  } else {    var xmlhr = new ActiveXObject('MSXML2.XMLHTTP.3.0');  }  xmlhr.open('POST', filePath, true);  xmlhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');  xmlhr.onreadystatechange = function() {    if (xmlhr.readyState == 1) {    } else if (xmlhr.readyState == 4 && xmlhr.status == 200) {      if (xmlhr.responseText) {        var Id = xmlhr.responseText;        alert(Id); // <-- this works        return Id; // <-- this doesn't return if I do a call: var myId = getId(xx,xx);      }    } else if (xmlhr.readyState == 4) {      alert('Invalid response received - Status: ' + xmlhr.status);    }  }  xmlhr.send(params);}