在我的网络应用程序中使用$.ajax
从api获取数据...它适用于除移动设备上的chrome之外的所有浏览器...当我使用chrome控制台模拟时(我选择galaxy作为设备)并检查问题...很明显,在移动设备上,$ .agax网址返回404,但如果我将该网址复制到新标签(未模拟),则不会有404 ...
这是我正在打电话。
// both of the following urls have the same results
var api_url = "https://pmp.psft.co/api/v2/collections/" + collection_id + "/contents?access_token="+token_cookie;
var api_url = '/collections/' + collection_id + '/contents.json';
$.ajax({
url : api_url,
type : "get",
async: false,
data: {per_page: perPage, page: currentPage},
success : function(collectionData) {
build_collection(collectionData);
console.log('success collection data');
},
error: function(){
console.log('error collection data');
}
});
你可以在这里看到它自己:https://sod3_omar.pmp.psft.co/collection?handle=communications&lang=en&tag=oh ...你会看到除了移动设备之外的所有浏览器都会加载内容。在检查工具中模拟星系时检查以查看404。
错误跟踪:
jquery.js:9664 GET https://pmp.psft.co/api/v2/collections/4ef6af98-f38c-440c-bc04-863e4d34332b…e6e27a3b01b9812b829fdde87d387d7eae50e304181224e2c456faff&per_page=6&page=1 404 (Not Found)
send @ jquery.js:9664
ajax @ jquery.js:9215
get_collection @ collection.js:22
which_collection @ collection.js:208
(anonymous) @ collection.js:246