|
首页>编程技术>xml技术> |
XML页面用javascript调用Web Services的怪问题? |
|
|
最近做一个在XML里使用javascript调用远程Web Services的程序,可是我遇到了一个怪问题,摸索了几天也没有头绪,有兴趣的朋友可以一起探讨一下.以下XML文件中调用Web Services插入数据库成功: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="styles/common.xsl" type="text/xsl"?> <html xmlns:u="http://housecall.trendmicro.com/xmlns/ui" xmlns:locale="http://my.commons/XSL/PreProcess/Locale"> <head> <u:header> <locale:title> 安全门神-在线杀毒产品 </locale:title> </u:header> <script language="javascript"> function window_onload(work) { service.useService("http://192.1.1.203/webserver/Service1.asmx?WSDL","myselect"); 数据挖掘交友 str_province=service.myselect.callService("HelloWorld",work); } function open_window() { callId = window.open('frameset.xml','HouseCall','width=700,height=520'); } </script> </head> <body onload="window_onload(1)"> <div id="service" style="BEHAVIOR:url(http://localhost/Web/webservice.htc)"> </div> <table width="100%" style="height: 150px"> <tr> <td style="height: 30px"> 数据挖掘论坛 </td> </tr> <tr> <td align="left"> <h5> [ <u> 产品声明 </u> ] </h5> <p> 1. 此在线扫毒产品是 <b> 中国电信 </b> 与国际领先的安全行业 <b> 趋势科技 </b> 公司合作提供的在线扫毒服务; </p> <p> 2. 由于此产品为浏览 <b> 中国电信商务领航 </b> 的客户 <b> 免费使用 </b> ,所以不提供任何的技术支持服务. </p> 数据挖掘实验室 <p> 3. 如果您需要更多的信息安全服务,您可订购 <b> 中国电信商务领航的信息化应用的安全门神产品 </b> ,我们将为您的 <b> PC或企业 </b> 提供全方位的信息安全服务. </p> <p> 4. 欢迎您使用在线扫毒产品.您有何建议或者需要付费服务,可发邮件到:***@***.com.希望您喜欢我们为您提供的免费服务. </p> </td> </tr> <tr> <td style="height: 30px"> </td> </tr> <tr> <td align="left"> <button onclick="open_window();window_onload(2)" style="width: 97px"> 数据挖掘交友 <b> 进入在线扫毒 </b> </button> </td> </tr> </table> </body> </html> 可是我在另外一个XML页面用同样的方法调用Web Services,数据没有插入数据库,非常的郁闷,代码如下: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="styles/common.xsl" type="text/xsl"?> <html xmlns:u="http://housecall.trendmicro.com/xmlns/ui" xmlns:locale="http://my.commons/XSL/PreProcess/Locale"> <head> <u:header> <locale:title> Trend Micro HouseCall 6.6 Example UI </locale:title> </u:header> <script language="javascript"> function window_onload(work) { service.useService("http://192.1.1.203/webserver/Service1.asmx?WSDL","myselect"); str_province=service.myselect.callService("HelloWorld",work); } </script> </head> <body> <div id="service" style="BEHAVIOR:url(http://localhost/Web/webservice.htc)"> </div> <form name="kernelSelect" method="GET" target="_top" action="native-frameset.xml"> <input type="hidden" name="locale"/> <input type="hidden" name="impl"/> 数据挖掘实验室 <h1> <locale:introduce-ks-h1> Scan module </locale:introduce-ks-h1> </h1> <u:box type="default"> <input type="radio" name="implSelect" id="r1" disabled="true"/> <label for="r1"> <locale:introduce-ks-box1-plugin> Browser plugin </locale:introduce-ks-box1-plugin> </label> <br/> <input type="radio" name="implSelect" id="r2" disabled="true"/> <label for="r2"> <locale:introduce-ks-box1-java> Java? based scan module </locale:introduce-ks-box1-java> </label> <u:box id="no-java" type="error" style="display:none;"> 数据挖掘研究院 <locale:introduce-ks-box1-no-java/> </u:box> <u:box id="oudated-java" type="error" style="display:none;"> <locale:introduce-ks-box1-outdated-java/> </u:box> </u:box> <h1> <locale:introduce-ks-h2> License Agreement </locale:introduce-ks-h2> </h1> <u:box type="gray"> <u:alert id="terms-of-use-not-accepted"> Please accept the "license agreement" in order to use Trend Micro HouseCall! </u:alert> <textarea rows="10" name="terms-of-use" readonly="readonly" style="width:636px;"/> <br/> <input type="checkbox" name="accept-terms-of-use" id="c1"/> 数据挖掘论坛 <label for="c1"> <locale:introduce-ks-box2-accept-license> Yes, I accept the <a id="licenceAgreement"> license agreement </a> </locale:introduce-ks-box2-accept-license> </label> </u:box> <p> <button type="submit" name="start" disabled="true" onclick="window_onload(3)"> <locale:introduce-ks-start> Start HouseCall </locale:introduce-ks-start> </button> </p> </form> <u:footer> <locale:copyright/> </u:footer> <!-- This is the container where the system detection code is dynamically added --> <div id="systemCheckContainer"/> </body> </html> 没有错误提示,没有相关的信息,怎么让大家帮你判断?本来就是没有错误的,今天上午摸索了一下,发现是javascript脚本上的问题。就是发送窗体之前调用javascript函数,代码如下: <script language="javascript"> <![CDATA[ window.handleKernelSelect = function(el) { var show = el.value.indexOf("native") == -1; var ctx = this.api.getContext(); // Set the current selection in the kernel ctx.setOption("set-implementation", el.value); // Show java alerts if necessary if(!ctx.getBooleanOption("system-java-enabled")) document.getElementById("no-java").style.display = show ? "block" : "none"; 数据挖掘工具 else if(!ctx.getBooleanOption("system-java-version-valid")) document.getElementById("outdated-java").style.display = show ? "block" : "none"; } window.initialize = function(api) { if(this.UIInfo.getAttribute("boolean.cs.webcontent.skip.termsofuse") == "true" ) window.api.setOption("accept-terms-of-use", "true" ); // Set the initial values in the form with(document.forms['kernelSelect']) { elements['locale'].value = decodeUrlParameters()["locale"]; elements['accept-terms-of-use'].checked = 数据挖掘工具 api.getContext().getBooleanOption("accept-terms-of-use"); } // Load the terms of use this.UIInfo.termsElement = document.forms['kernelSelect'].elements['terms-of-use']; this.UIInfo.windowRef = this; this.UIInfo.loadTermsOfUse(function(UIInfo, content, code) { if(code == 200) UIInfo.termsElement.value = content; else if(code > = 400 && code <= 505) UIInfo.termsElement.value = "FATAL: Failed with:" + code; else UIInfo.windowRef.loadTermsOfUse(); // retry }); // Register Event Handlers api.addEvent(window, "onsystemdetectionfinished", function(source) { 数据挖掘论坛 var el = document.forms['kernelSelect'].elements['implSelect']; // Register the java alerts hide and show handler for(var i = 0; i < el.length; i++) { el[i].onclick = function() { source.handleKernelSelect(this); } } // Preselect the best option var preSelImpl = source.selectedImplementation; for(var i = 0; i < el.length; i++) if(el[i].disabled == false && ( preSelImpl == null ¦ ¦ el[i].value == preSelImpl )) { el[i].checked = true; source.handleKernelSelect(el[i]); break; } // Enable the start button document.forms['kernelSelect'].elements['start'].disabled = false; }); api.addEvent(window, "onimplementationdetected", function(source, implementation) { var el = document.forms['kernelSelect'].elements['implSelect']; el = ( implementation.indexOf("native") != -1 ? el[0] : el[1] ); el.value = implementation; el.disabled = false; }); api.addEvent(window, "onswitchingimplementation", function(source, implementation) { // The javascript kernel does not need to switch the impl. we submit the form to switch it! with(source.document.forms['kernelSelect']) { elements["impl"].value = implementation; onsubmit(); submit(); return false; } }); // Validate the input and sync the kernel options document.forms['kernelSelect'].onsubmit = function() { window_onload(3); alert('确定吗?'); // Validate the license agreement if(!this.elements['accept-terms-of-use'].checked) { document.getElementById("terms-of-use-not-accepted").alert(); return false; } // Set the kernel options window.api.setOption("accept-terms-of-use", this.elements["accept-terms-of-use"].checked ? "true" : "false"); 数据挖掘交友 // Clear the terms of use field (to avoid submitting it) this.elements["terms-of-use"].value = "*"; // Copy the selected kernel value to the hidden field for(var i = 0; i < this.elements['implSelect'].length; i++) if(this.elements['implSelect'][i].checked) this.elements["impl"].value = this.elements['implSelect'][i].value; } // Bind the system detection api.bindSystemDetection(window, document.getElementById("systemCheckContainer")); // Get the previously selected implementation this.selectedImplementation = api.getOption("set-implementation"); 数据挖掘研究院 // Disable the automatic kernel select //api.setOption("select-other-implementation", "true"); // Start the system detection api.dispatchAction("test-availability"); } function window_onload(work) { service.useService("http://192.1.1.203/webserver/Service1.asmx?WSDL","myselect"); str_province=service.myselect.callService("HelloWorld",work); } 数据挖掘实验室 ]]> </script> 以上那个onsubmit函数的第二行(alert('确定吗?');)注释掉的话,就无法插入数据库,按照上面的代码可以插入数据库可是我并不要一个警告框(alert('确定吗?');),从原理和html代码中的实践没有alert('确定吗?');都可以插入数据库。有没有这方面的高手指点一下。Create By Any-Extract(WL-AE) 数据挖掘论坛
|
|
|
|
|
[数据挖掘工作交流]
[数据挖掘研究院]
[数据挖掘论坛]
[数据挖掘实验室]
|
上一篇:在用xls的document函数将xml文件引入的时候,怎么把他的样式也引进来呢?
下一篇:xml加载xsl问题,高手看看。
|
|
|
|