XMLHttpRequest在cordova 3.3中不起作用

时间:2014-02-04 12:40:19

标签: cordova

我正在使用Web服务(SOAP)来使用来自外部源的数据,

我能够使用eclipse网络浏览器获得响应,但无法在Android设备和模拟器中工作(我的响应为0)

var xmlhttp = new XMLHttpRequest();
xmlhttp.open('POST', 'http://hmecd000910/ClubdService/ClubDSecurityService.svc', true);

var sr = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">'+
'<soapenv:Header/>'+
'<soapenv:Body>'+
   '<tem:GetUserByUserEmail>'+      
      '<tem:userEmail>nc@usl.com</tem:userEmail>'+
   '</tem:GetUserByUserEmail>'+
'</soapenv:Body>'+
'</soapenv:Envelope>';

 xmlhttp.onreadystatechange = function () {         
    if (xmlhttp.readyState == 4) {
         alert(xmlhttp.status+'--'+xmlhttp.readyState);
     if (xmlhttp.status == 200) {           
         alert(xmlhttp.responseText);
    }     
    // alert(xmlhttp.responseText);
  }
}

xmlhttp.setRequestHeader('Content-Type', "text/xml; charset=\"utf-8\"");
xmlhttp.setRequestHeader('Content-length',sr.length);
xmlhttp.setRequestHeader('SOAPAction', 'http://tempuri.org/IUSLClubDSecurityService/GetUserByUserEmail');

xmlhttp.send(sr);  

我已按以下方式配置了config.xml,

<access origin="*" />

1 个答案:

答案 0 :(得分:0)

嘿尝试下面的代码

$.post( ipAddress +"/acb.php", { user_id:userID,password:pwd} , function( data ) {
                                                                if(data.status==true){
                                                                         //response 
                                                                }
                                                              },"json");