// // A simple funcition that will call xhSend4() // function just_a_test() { resposta = xhSend4('&i=i'); } function xhSend4(string){ function createXMLHttpRequest() { try{ return new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){} try{ return new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){} try{ return new XMLHttpRequest(); }catch(e){} alert("XMLHttpRequest not supported"); return null; } var xhReq = createXMLHttpRequest(); xhReq.open("post","index.php",true); xhReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhReq.onreadystatechange = function do_readyStateChange() { if (xhReq.readyState == 4) { // // How can i pass back this variable called "resposta" to the function just_a_test() // reposta = xhReq.responseText; } } xhReq.send(string); }