2000-06-30 23:10:56 +00:00
|
|
|
<html>
|
|
|
|
<body>
|
|
|
|
<h1>Posting test</h1>
|
|
|
|
<script>
|
2001-02-28 23:46:59 +00:00
|
|
|
const WSTRING_CONTRACTID = "@mozilla.org/supports-wstring;1";
|
|
|
|
|
|
|
|
var sendPlainTextData = false; // you can only create the text string if you can bybass security
|
|
|
|
|
|
|
|
var x;
|
|
|
|
if (!sendPlainTextData) {
|
|
|
|
x = document.implementation.createDocument("", "test", null);
|
|
|
|
x.documentElement.appendChild(document.createTextNode("Foo"));
|
|
|
|
}
|
2000-06-30 23:10:56 +00:00
|
|
|
|
|
|
|
var p = new XMLHttpRequest();
|
2001-02-28 23:46:59 +00:00
|
|
|
|
2000-06-30 23:10:56 +00:00
|
|
|
function myfunc()
|
|
|
|
{
|
2001-02-28 23:46:59 +00:00
|
|
|
var s = new XMLSerializer();
|
|
|
|
var str;
|
|
|
|
if (!sendPlainTextData) {
|
|
|
|
var d = p.responseXML;
|
|
|
|
str = s.serializeToString(d);
|
|
|
|
} else {
|
|
|
|
str = p.responseText;
|
|
|
|
}
|
2000-06-30 23:10:56 +00:00
|
|
|
alert(str);
|
|
|
|
alert(p.getAllResponseHeaders());
|
|
|
|
}
|
2001-02-28 23:46:59 +00:00
|
|
|
|
2000-06-30 23:10:56 +00:00
|
|
|
p.onload = myfunc;
|
2001-03-02 00:09:20 +00:00
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
|
2001-06-01 23:44:03 +00:00
|
|
|
p.open("POST", "http://green/cgi-bin/echo_xml.cgi");
|
2001-02-28 23:46:59 +00:00
|
|
|
|
|
|
|
if (!sendPlainTextData) {
|
|
|
|
p.send(x);
|
|
|
|
} else {
|
|
|
|
var mystr = Components.classes[WSTRING_CONTRACTID].createInstance(Components.interfaces.nsISupportsWString);
|
|
|
|
mystr.data = "Heikki's data";
|
|
|
|
p.send(mystr);
|
|
|
|
}
|
2000-06-30 23:10:56 +00:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|