I have this javascript code, the problem is that i can only call it once, after that it won't work again ... If I copy and paste the function it will still not work , until i will change variable Ajax into something else like Ajax2... but this involve some copy&paste work , and i want to have it for unlimited hits.. Declaring Ajax on the top won't work , doing Ajax an vector as Ajax[x] won't work <script type="text/javascript"> function trimite(url, parametri, divname){ if (window.XMLHttpRequest) { Ajax = new XMLHttpRequest(); } else if (window.ActiveXObject) { if(!Ajax){Ajax = new ActiveXObject("Msxml2.XMLHTTP");} if(!Ajax){Ajax = new ActiveXObject("Microsoft.XMLHTTP");} } function schimbari(){ if(Ajax.readyState == 4){document.getElementById(divname).innerHTML=Ajax.responseText;} } Ajax.overrideMimeType('text/html'); Ajax.open('POST',url,true); Ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded') Ajax.setRequestHeader("Content-length", parametri); Ajax.setRequestHeader("Connection", "close"); Ajax.send(parametri); Ajax.onreadystatechange = schimbari; } </script> HTML:
How do you use the function? do you call trimite once and schimbari more than once? That could be the problem. Your Ajax may be used only once.