iphone上的HTTPS请求未发送到服务器

时间:2013-06-16 13:21:52

标签: iphone ios cordova

我正在使用phonegap开发iphone应用程序。 使用HTTP提交ajax请求时,一切正常。但是当我切换到HTTPS时,请求不会发送到服务器。相同的代码适用于Android上的HTTP和HTTPS。

以下是我正在使用的代码,感谢您提前提供的帮助

var xmlRequest = $.ajax({
    url : "https://test.com",
    type : 'POST',
    contentType : "text; charset=utf-8",
    data : sr,
    dataType : "text",
    headers : { SOAPAction : '"'+soapaction+ '"' },
    success : function( data, textStatus, jqXHR ) {
        console.log("----- xmlRequest.responseText: " + xmlRequest.responseText);
        SOAPClient._onSendSoapRequest(method, async, callback, sch, data);
    },
    error : function( jqXHR, textStatus, errorThrown ) {
        console.log("----- xmlRequest.responseText: " + xmlRequest.responseText);
        console.log("----- errorThrown = " + errorThrown + " textStatus = "+ textStatus );
        ServiceErrorMessage(method, jqXHR.status, errorThrown, xmlRequest.responseText);
    },
    cache: false
});

1 个答案:

答案 0 :(得分:0)

将其添加到AppDelegate.m文件的末尾

@implementation NSURLRequest(DataController)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host
{
    return YES; 
}
@end