[英]AJAX request (HTTPS) not responding on iPhone
$(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!");
});
});
async
和cache
设置为false
只是为了确保不从缓存中获取数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.