AJAX 请求 (HTTPS) 在 iPhone 上没有响应

AJAX request (HTTPS) not responding on iPhone

本文关键字:响应 iPhone 请求 HTTPS AJAX      更新时间:2023-09-26
$(function () {
    var apiEndpoint = "https://www.myaddress.com/api/";
    var getVersion = $.ajax({
        url: apiEndpoint + "version/",
        dataType: "JSON",
        username: "myuser",
        type: "GET",
        password: "mypass"
    });
    getVersion.done(function (version) {
        alert("HEY!!!!!!!!!!");
    });
    getVersion.fail(function () {
        alert("I'm not invoked either!");
    });
});

此代码在我的桌面上的 Chrome 上运行良好,但在 iPhone 上调用该页面时,没有显示警报。知道为什么会这样吗?

我有一种感觉,这是因为 https:// ,但为什么这只是 iPhone 上的问题,我该如何解决它?

尝试使用以下代码:

$(function () {
var apiEndpoint = "https://www.myaddress.com/api/";
var getVersion = $.ajax({
    url: apiEndpoint + "version/",
    dataType: "JSONP",
    username: "myuser",
    type: "GET",
    password: "mypass",
    async:false,
    cache:false,
});
getVersion.done(function (version) {
    alert("HEY!!!!!!!!!!");
    });
getVersion.fail(function () {
    alert("I'm not invoked either!");
    });
});

asynccache设置false只是为了确保不会从缓存中获取数据。