plz幫助,無法調用使用PhoneGap的AJAX(簡單的JavaScript)基於REST的Web服務的IPhone
我只是在我的新的PhoneGap的iPhone應用程序調用基於REST Web服務。
我正在使用XCode 3.2.3,其中我安裝了PhoneGap框架,它工作正常。
開發了一個使用AJAX的簡單JavaScript代碼。以下是代碼。
此代碼工作正常的在: IE,Morzilla和Safari我的Mac電腦的瀏覽器還對iPhone模擬器 Safari瀏覽器,但是當我在這個代碼集成我的PhoneGap應用程序的index.html
在WWW文件夾它不給任何迴應。
<html> <head> <script language="javascript" type="text/javascript"> function callingRestBasedWebService() { alert('In callingRestBasedWebService'); var username = document.getElementById('usernameid').value; var password = document.getElementById('passwordid').value; var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { var responseXML = xmlhttp.responseText; alert("ResponseXML="+responseXML); if (window.DOMParser) //Creating DOM Object for Morzilla for parsing XML { parser=new DOMParser(); xmlDoc=parser.parseFromString(responseXML,"text/xml"); } else // Internet Explorer // Creating DOM object for IE for parsing XML { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async="false"; xmlDoc.loadXML(responseXML); } x=xmlDoc.getElementsByTagName("Login"); if(x[0].getElementsByTagName("status")[0].childNodes[0].nodeValue == 'Success') { alert('Login Successfull'); }else { alert('Login Failed'); } } } xmlhttp.open("GET","http://pc-a401115.patni.com:8080/BankWebService/resources/validateLogin?username="+username+"&password="+password,true); xmlhttp.send(); } </script> </head> <body> <br><br> Username : <input type="text" name="username" id="usernameid"><br><br> Password :<input type="text" name="password" id="passwordid"><br><br> <input type="button" name="Login" value="Login" onClick="javascript:callingRestBasedWebService();"> </body> </html>
有人能幫助我,並告知PLZ如果我錯了一些地方..
感謝, MobileAppMaster
嘿,我試圖調用使用該方法的Web服務,但它不工作,使用XUI API。你可以看我的博客http://kmithi.blogspot.in/2012/02/callling-web-services-in.html – mithilesh 2012-03-23 13:57:39