Mam kod :
<script language="JavaScript">
function processData(data) {
document.write(data);
}
function handler() {
document.MainForm.fileURL.value = this.readyState;
if (this.readyState == 4)
{
processData(this.responseText);
}
}
function submitForm() {
var xhr = null;
try
{
xhr = new XMLHttpRequest();
xhr.overrideMimeType('text/xml');
}
catch(e)
{
try
{
xhr = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e2)
{
alert("An exception occurred in the script. Error name: " + e.name + ". Error message: " + e.message);
}
}
xhr.onreadystatechange = handler;
xhr.open('GET','http://google.pl', true);
xhr.send("");
}
<FORM method="POST" name="MainForm" action=""> <INPUT type="text" name="fileURL" value="testURL"> <INPUT type="submit" value="Pobierz" ONCLICK="submitForm()">
Dlaczego to nie działa ? Czasem daje w wyniku "1" a czasem "2" (w polu fileURL czyli wartość this.readyState).