var request = new XMLHttpRequest(); request.open('POST','a10.pdf', true); if (request.status >= 200 && request.status < 300)
Da fehlt Einiges. Ich mache es so:
request.open('post', url, true); // Request öffnen
request.send(null); // Request senden
request.onreadystatechange = zeigeHelptext; // Request auswerten
...
function zeigeHelptext( )
{
// http://www.w3schools.com/ajax/ajax_xmlhttprequest_onreadystatechange.asp
// The onreadystatechange event is triggered every time the readyState changes.
if ( request.readyState == 4 && request.status == 200 )
{
document.getElementById( "helptext" ).innerHTML = request.responseText;
document.getElementById( "helptext" ).style.display = "block";
}
}
Info:
onreadystatechange
Stores a function (or the name of a function) to be called automatically each time the readyState property changes
readyState
Holds the status of the XMLHttpRequest. Changes from 0 to 4:
0: request not initialized
1: server connection established
2: request received
3: processing request
4: request finished and response is ready
status
200: "OK"
404: Page not found
Also warte den readyState == 4
ab und prüfe dann auf status == 200
Datei geladen oder status == 404
Datei nicht erreichbar.
Linuchs