Kod :
<html> <head> <script type="text/javascript"> <!-- function submitForm(){ var xhr; if (window.XMLHttpRequest) { xhr = new XMLHttpRequest(); alert('opera'); } else if (window.ActiveXObject) { try { xhr= new ActiveXObject("Msxml2.XMLHTTP"); } catch (e){ try{ xhr = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e3){ xhr=false; } } } xhr.open('POST','data.txt',true); xhr.send(null); xhr.onReadyStateChange=processReqChange(); function processReqChange(){ alert(xhr.readyState); if(xhr.readyState == 4){ alert('test2'); if(xhr.status == 200){ var doc = xhr.responseTEXT; alert('test3'); document.getElementById('element1').innerHTML= doc; // Assign the content to the form alert( xhr.status); } else{ document.getElementById('element1').innerHTML="Kod błędu: "+xhr.status; } } } } --> </script> </head> <body onLoad="submitForm();" > </body> </html>
Zachowanie:
- IE 6.0: wyświetla treść pliku data.txt
- firefox 3.0.5: zamiast podmienić element1 na tresc- wyświetla 'undefinied'
- opera 9.63: nic nie wyświetla.
Problem pewnie banał, jednak byłbym bardzo wdzięcznym za pomoc:)
Pzdr.