Re: Problems retrieving data from form fields for non-encrypted host

"Siegfried Heintze" <[email protected]>
Newsgroups gmane.comp.mozilla.devel.xml
Organization Another Netscape Collabra Server User
Message-ID <[email protected]>
Thanks Martin.

The message is: "The information you have entered is to be sent over an
unencrypted connection and could easily be read by a thired party.

Are you sure you want to continue sending this information?"

At this point, I can see it has already correctly called my web service,
received the data and displayed the correct sum. Now, when I press continue,
the entire page is restored to its appearence before pressing my "add"
button.

The code is below.
Thanks,
Siegfried

   1 <html>
   2 <!-- 
   3   $Log: xpost.html,v $
   4   Revision 1.4  2005/01/16 20:42:19  Siegfried
   5   Add code to traverse the DOM to extract answer and display it.

   6
   7   Revision 1.3  2005/01/16 06:33:23  Siegfried
   8   Addition works!
   9
  10   Revision 1.2  2005/01/16 04:46:21  Siegfried
  11   Original from
http://lxr.mozilla.org/seamonkey/source/extensions/xmlextras/tests/xpost.html
  12
  13 -->
  14 <head><title>POST test</title>
  15 <style type="text/css">
  16 .box {
  17   display: box;
  18   border: 1px solid black;
  19   margin-bottom: 0.5em;
  20 }
  21 .boxheader {
  22   font-weight: bold;
  23   color: maroon;
  24 }
  25 pre {
  26   margin-left: 2em;
  27 }
  28 </style>
  29 <script type="text/javascript">
  30 var sURL = "http://localhost/convex/CaseAssessment/";
  31 var sNS = "http://www.heintze.com/AnalyzeResults";
  32 var sFunc = "addition";
  33 var again_dbg = true;
  34 var p;
  35 //add();
  36 function add(){
  37   try {
  38     // Needed for Mozilla if local file tries to access an http URL
  39
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
  40   } catch (e) {
  41     // ignore
  42   }
  43 //  var aa = document.main.a.value, bb= document.main.b.value;
  44   var aa=322.33, bb=298.22;
  45   document.main.a.value=""+aa;  document.main.b.value=""+bb;
  46   try {
  47     p = new XMLHttpRequest();
  48   } catch (e) {
  49     p = new ActiveXObject("Msxml2.XMLHTTP");
  50   }
  51
  52   // In Mozilla, you can only create the text string if you can bybass
security, like in chrome
  53   var x;
  54     x = document.implementation.createDocument("", "", null);
  55     x = (new DOMParser()).parseFromString('<?xml
version="1.0"?><soap:Envelope xmlns:soap=
"http://schemas.xmlsoap.org/soap/envelope/"'+
  56                     ' xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"' +
  57                     ' xmlns:xsd= "http://www.w3.org/2001/XMLSchema">' +
  58                  ' <soap:Body>' +
  59                    '<'+sFunc+' xmlns="'+sNS+'">' +
  60                      '<x>'+aa+'</x>' +
  61                      '<y>'+bb+'</y>' +
  62                    '</addition>' +
  63                  ' </soap:Body>' +
  64                  ' </soap:Envelope>', "text/xml");
  65   //if(again_dbg) again_dbg=confirm('x ='+ (new
XMLSerializer()).serializeToString(x));
  66
  67   var interactiveCount = 0;
  68
  69
  70   // p.onload would also work in Mozilla
  71   p.onreadystatechange = myfunc;
  72
  73
  74   p.open("POST", sURL+"/Service1.asmx");
//"http://green/cgi-bin/echo_xml.cgi");
  75   p.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
  76   p.setRequestHeader("SOAPAction", sNS+"/"+sFunc);
  77   //
http://unstable.elemental.com/mozilla/build/latest/mozilla/extensions/dox/interfacensIXMLHttpRequest.html
  78   p.send(x);
  79 }
  80 function myfunc(){
  81   if (p.readyState == 3) interactiveCount++;
  82
  83 //  if(again_dbg)again_dbg=confirm(p.readyState);
  84   if (p.readyState == 2) {
  85 //    if(again_dbg)again_dbg=confirm(p.getAllResponseHeaders());
  86 //    if(again_dbg)again_dbg=confirm(p.status);
  87   }
  88   if (p.readyState != 4)
  89     return;
  90
  91   document.getElementById("id1").firstChild.nodeValue = p.responseText;
  92
  93   if (p.responseXML) {
  94     var str, s, d;
  95     try {
  96       s = new XMLSerializer();
  97       d = p.responseXML;
  98       str = s.serializeToString(d);
  99     } catch (e) {
 100       str = "@@TODO@@";
 101     }
 102     document.getElementById("id2").firstChild.nodeValue = str;
 103     try{
 104       document.getElementById("id8").firstChild.nodeValue = (new
XMLSerializer()).serializeToString(d.firstChild.firstChild.firstChild.firstC
hild.firstChild);
 105     }
 106     catch(e){
 107       document.getElementById("id8").firstChild.nodeValue = "@@Broke@@"
 108     }
 109   }
 110   document.getElementById("id3").firstChild.nodeValue =
p.getAllResponseHeaders();
 111   document.getElementById("id4").firstChild.nodeValue = p.status;
 112   document.getElementById("id5").firstChild.nodeValue = p.statusText;
 113   document.getElementById("id6").firstChild.nodeValue = p.readyState;
 114   document.getElementById("id7").firstChild.nodeValue =
interactiveCount;
 115 }
 116 </script>
 117
 118 </head>
 119   <body>
 120     <form name=main>
 121       <h1>POST test</h1>
 122 <!--
 123       <p><a
href="http://lxr.mozilla.org/seamonkey/source/extensions/xmlextras/tests/">h
ttp://lxr.mozilla.org/seamonkey/source/extensions/xmlextras/tests/</a></p>
 124       <p><a
href="http://lxr.mozilla.org/mozilla/source/extensions/webservices/docs/Soap
_Scripts_in_Mozilla.html#3.2_Basic_Operations_of_SOAP">http://lxr.mozilla.or
g/mozilla/source/extensions/webservices/docs/Soap_Scripts_in_Mozilla.html#3.
2_Basic_Operations_of_SOAP</a></p>
 125       <p><a
href="http://lxr.mozilla.org/seamonkey/source/extensions/webservices/soap/te
sts/soapisprimenumber.html">http://lxr.mozilla.org/seamonkey/source/extensio
ns/webservices/soap/tests/soapisprimenumber.html</a></p>
 126       <p><a href="http://www.mozilla.org/xmlextras/">XML </a></p>
 127       <p><a
href="http://lxr.mozilla.org/seamonkey/source/extensions/xmlextras/tests/xpo
st.html">This sample.</a></p>
 128       <p><a href="http://www.arachnion.de/conf2004/xul1.pdf">XUL and
SOAP</a></p>
 129   -->
 130
 131       <div class="box" style=border:110 ><span
class="boxheader">Test</span>
 132         <button  style=border:110  OnClick="add();">Add</button>
 133         <input style=border:110 type=text value=833.22 name=a />
 134         <input style=border:110  type=text value=229.22 name=b />
 135       </div>
 136       <div class="box"><span class="boxheader">Results</span>
 137       <pre id="id8"
OnMouseOver="this.style.fontSize='xx-large';this.style.fontWeight='bold';"
OnMouseOut="this.style.fontSize='medium';
this.style.fontWeight='normal';">@@No result@@</pre>
 138       </div>
 139       <div class="box"><span class="boxheader">responseText</span>
 140       <pre id="id1"
OnMouseOver="this.style.fontSize='xx-large';this.style.fontWeight='bold';"
OnMouseOut="this.style.fontSize='medium'; this.style.fontWeight='normal';"
>@@No result@@</pre>
 141       </div>
 142       <div class="box"><span class="boxheader">responseXML
serialized</span>
 143       <pre id="id2"
OnMouseOver="this.style.fontSize='xx-large';this.style.fontWeight='bold';"
OnMouseOut="this.style.fontSize='medium';
this.style.fontWeight='normal';">@@No result@@</pre>
 144       </div>
 145       <div class="box"><span
class="boxheader">getAllResponseHeaders()</span>
 146       <pre id="id3"
OnMouseOver="this.style.fontSize='xx-large';this.style.fontWeight='bold';"
OnMouseOut="this.style.fontSize='medium';
this.style.fontWeight='normal';">@@No result@@</pre>
 147       </div>
 148       <div class="box"><span class="boxheader">status</span>
 149       <pre id="id4"
OnMouseOver="this.style.fontSize='xx-large';this.style.fontWeight='bold';"
OnMouseOut="this.style.fontSize='medium';
this.style.fontWeight='normal';">@@No result@@</pre>
 150       </div>
 151       <div class="box"><span class="boxheader">statusText</span>
 152       <pre id="id5"
OnMouseOver="this.style.fontSize='xx-large';this.style.fontWeight='bold';"
OnMouseOut="this.style.fontSize='medium';
this.style.fontWeight='normal';">@@No result@@</pre>
 153       </div>
 154       <div class="box"><span class="boxheader">readyState</span>
 155       <pre id="id6"
OnMouseOver="this.style.fontSize='xx-large';this.style.fontWeight='bold';"
OnMouseOut="this.style.fontSize='medium';
this.style.fontWeight='normal';">@@No result@@</pre>
 156       </div>
 157       <div class="box"><span class="boxheader"># of times
onreadystatechanged handler called with INTERACTIVE status</span>
 158       <pre id="id7"
OnMouseOver="this.style.fontSize='xx-large';this.style.fontWeight='bold';"
OnMouseOut="this.style.fontSize='medium';
this.style.fontWeight='normal';">@@No result@@</pre>
 159       </div>
 160     </form>
 161   </body>
 162 </html>
 164





"Martin Honnen" <[email protected]> wrote in message
news:[email protected]...
>
>
> Siegfried Heintze wrote:
>
> > I'm pleased to say that I have a small web service client that runs in
> > Mozilla's javascript. I can add two numbers as long as I hard code the
> > addends in the java script.
> >
> > However, when I try to retreive the addends from some form fields, I get
a
> > dialog box that says I'm sending data to an unencrypted host and there
is a
> > single OK button.
>
> Reading a form field is simply
>    var value = document.forms.formName.elements.inputName.value;
> so Mozilla will hardly give you any dialog box about sending data
> unencrypted.
> You will need to show us exactly on how you use script to send data, I
> don't think that message depends on script getting a value from a form
> or not.
>
> > Unfortunately, I clicked the checkbox that says "do not show this
message
> > again". I wish I had not done that. How do I undo that?
>
> I think it is the preference named
>    security.warn_submit_insecure
> so you would need to change that back to true, one way to do that is
> loading the (pseudo) URL
> about:config
> into Mozilla, search for that preference and then change it
> (right-click->modify).
>
> > Anyway, prior to having unchecked that check box, I could see that they
(the
> > web service and client) were performing the addition correctly but as
soon
> > as I clicked the OK button, the form was restored to its previous state.
>
> Show us some code, a URL maybe, perhaps it is just an onclick or
> onsubmit handler firing and then reloading the page. It is not possible
> to tell what goes on from the textual description.
>
> And check the JavaScript console for any errors.
>
>
> -- 
>
> Martin Honnen
> http://JavaScript.FAQTs.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.