当使用ajax调用命中API时,出现以下错误

readyState":0,"status":0,"statusText":"error"


Ajax调用方法:

var deviceId = FCM_Tocken_localStorage_GET();
//console.log(" Status ~~~~~~~~~~~~~~~~~~~~~~~~~~~>  " + deviceId);
//  alert(deviceId);
//debugger
var site = window.localStorage.getItem("site_id");

$.ajax({
    url: baseURL + '/api/saveDeviceId?deviceId='+deviceId,
    type: 'POST',
    success: function(result) {
        console.log("ResponseMessage----------------> " + JSON.stringify(result));
       // alert(JSON.stringify(result));
        if (result.status == "success") {
        } else {
            }
  //      $(".modal").hide();
    },
    error: function(exception) {
     alert(JSON.stringify(exception));
  console.log('Exception:~~~~~~~~~~~~~~~~~~~~~> ' + exception);
 //       $(".modal").hide();
        }

})


请允许我帮助克服这个问题

最佳答案

最后我找到了答案,如下所述:

// A new webclient that ignore ssl errors
private class IgnoreSSLErrorWebViewClient extends WebViewClient {
    // You can call the class anything

@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error)
{
 handler.proceed(); // When an error occurs, ignore and go on
}
}
 The site has issues with SSL certificate verification. The default WebViewClient stops loading when there is an SSL verification error. This extension will instruct it to disregard the error and proceed.


from this link I found my answer 适用于webwiew的一个版本也适用于Cordova Android应用程序

10-07 19:45
查看更多