2 <head><title>POST test
</title>
3 <style type=
"text/css">
6 border: 1px solid black
;
17 <script type=
"text/javascript">
20 p
= new XMLHttpRequest();
22 p
= new ActiveXObject("Msxml2.XMLHTTP");
25 // In Mozilla, you can only create the text string if you can bybass security, like in chrome
26 var sendPlainTextData
= false;
28 var docsize
= 400; // the document has docsize*2+1 elements
30 if (!sendPlainTextData
) {
32 x
= document
.implementation
.createDocument("", "test", null);
34 for (i
= 0; i
< docsize
; i
++) {
35 var fooElement
= document
.createElement("Foo");
36 fooElement
.appendChild(document
.createTextNode("My Stuff\nYeah"));
37 x
.documentElement
.appendChild(fooElement
);
38 x
.documentElement
.appendChild(document
.createElement("Bar"));
41 x
= new ActiveXObject("Msxml2.DOMDocument");
42 var str
= "<?xml version='1.0'?>\n<test>";
44 for (i
= 0; i
< docsize
; i
++) {
45 str
+= "<Foo>My Stuff\nYeah</Foo><Bar/>";
52 var interactiveCount
= 0;
56 if (p
.readyState
== 3) {
59 //alert("myfunc readyState=" + p.readyState);
60 //if (p.readyState == 2) {
61 // alert(p.getAllResponseHeaders());
64 if (p
.readyState
!= 4)
67 document
.getElementById("id1").firstChild
.nodeValue
= p
.responseText
;
71 var s
= new XMLSerializer();
72 var d
= p
.responseXML
;
73 str
= s
.serializeToString(d
);
77 document
.getElementById("id2").firstChild
.nodeValue
= str
;
79 document
.getElementById("id3").firstChild
.nodeValue
= p
.getAllResponseHeaders();
80 document
.getElementById("id4").firstChild
.nodeValue
= p
.status
;
81 document
.getElementById("id5").firstChild
.nodeValue
= p
.statusText
;
82 document
.getElementById("id6").firstChild
.nodeValue
= p
.readyState
;
83 document
.getElementById("id7").firstChild
.nodeValue
= interactiveCount
;
86 // p.onload would also work in Mozilla
87 p
.onreadystatechange
= myfunc
;
90 // Needed for Mozilla if local file tries to access an http URL
91 netscape
.security
.PrivilegeManager
.enablePrivilege("UniversalBrowserRead");
96 //alert("before open():" +p.readyState);// 0 = UNINITIALIZED
97 p
.open("POST", "http://green/cgi-bin/echo_xml.cgi");
98 //alert("after open():" +p.readyState);// 1 = LOADING
100 if (!sendPlainTextData
) {
101 //alert("Going to send");
103 //alert("Done to send");
107 var WSTRING_CONTRACTID
= "@mozilla.org/supports-string;1";
108 mystr
= Components
.classes
[WSTRING_CONTRACTID
].createInstance(Components
.interfaces
.nsISupportsString
);
109 mystr
.data
= "Heikki's data";
111 mystr
= "Heikki's data";
115 //alert("after send():" +p.readyState);// 1 = LOADING
121 <div class=
"box"><span class=
"boxheader">responseText
</span>
122 <pre id=
"id1">@@No result@@
</pre>
124 <div class=
"box"><span class=
"boxheader">responseXML serialized
</span>
125 <pre id=
"id2">@@No result@@
</pre>
127 <div class=
"box"><span class=
"boxheader">getAllResponseHeaders()
</span>
128 <pre id=
"id3">@@No result@@
</pre>
130 <div class=
"box"><span class=
"boxheader">status
</span>
131 <pre id=
"id4">@@No result@@
</pre>
133 <div class=
"box"><span class=
"boxheader">statusText
</span>
134 <pre id=
"id5">@@No result@@
</pre>
136 <div class=
"box"><span class=
"boxheader">readyState
</span>
137 <pre id=
"id6">@@No result@@
</pre>
139 <div class=
"box"><span class=
"boxheader"># of times onreadystatechanged handler called with INTERACTIVE status
</span>
140 <pre id=
"id7">@@No result@@
</pre>