gpt4 book ai didi

javascript - AJAX 调用在 ipad 上不触发但在桌面上正常

转载 作者:行者123 更新时间:2023-11-29 03:21:39 25 4
gpt4 key购买 nike

我有以下自定义插件代码

(function ($) {
$.fn.createGallery = function(options) {
var theObject = $(this);
var settings = $.extend({
// These are the defaults.
server: 'http://localhost/jQuery%20Gallery/images/galleries/homepage_gallery',
galleryName: 'Test',
galleryWidth: theObject.parent().width(),
galleryImageMargin: 20,
galleryImageColumns: 2,
imageQuality: 100
}, options);

var galleryImageWidth = settings.galleryWidth / settings.galleryImageColumns;
var imageUrl = settings.server;

var otherMargin = Math.round(settings.galleryImageMargin / 2);
var finalImageWidth = Math.round(galleryImageWidth - settings.galleryImageMargin);
var finalImageHeight = Math.round(galleryImageWidth / 1.4);
var finalGalleryWidth = settings.galleryWidth - settings.galleryImageMargin;

$(this).before('<style>'+$(this).selector+' li:nth-child('+settings.galleryImageColumns+'n+1) { margin-left: 0; } '+$(this).selector+' li:first-child { margin-left: 0; } '+$(this).selector+' { width: '+finalGalleryWidth+'px; margin: 0px; } '+$(this).selector+' li { display: inline-block; list-style: none; margin-left: '+settings.galleryImageMargin+'px; margin-bottom: '+otherMargin+'px; } </style>');

$.ajax({
url: imageUrl,
success: function(data){
console.log('SUCCESS');
var extension = '.jpg';
$(data).find("a:contains("+extension+")").each(function(){
// will loop through
var filename = $(this).attr("href");
$('<li></li>').html('<a href="'+imageUrl+'/'+filename+'" class="fancybox"><img src="thumbnail.php?src='+imageUrl+'/'+filename+'&q='+settings.imageQuality+'&h='+finalImageHeight+'&w='+finalImageWidth+'"/></a>').appendTo(theObject);
});
theObject.children('li:nth-child('+settings.galleryImageColumns+'n+1)').addClass('triggerMarginIE8');
},
failure: function(data){
console.log('FAIL');
}
});
};
}(jQuery));

据我所知,这在我的桌面上运行良好。然而,AJAX 无法在 iOS 设备(可能还有其他设备)或同事的机器上正常触发,它说该文件夹已被永久移动,但实际上并没有!

有什么想法吗?我知道 AJAX 何时运行或不运行是因为 console.log

最佳答案

尝试在 url 中输入相对路径。 :)

   server: 'images/galleries/homepage_gallery', //your relative path...
var imageUrl = settings.server;

//Ajax call
$.ajax({
url: imageUrl,
success: function(data){
console.log('SUCCESS');
var extension = '.jpg';
$(data).find("a:contains("+extension+")").each(function(){
// will loop through
var filename = $(this).attr("href");
$('<li></li>').html('<a href="'+imageUrl+'/'+filename+'" class="fancybox"><img src="thumbnail.php?src='+imageUrl+'/'+filename+'&q='+settings.imageQuality+'&h='+finalImageHeight+'&w='+finalImageWidth+'"/></a>').appendTo(theObject);
});
theObject.children('li:nth-child('+settings.galleryImageColumns+'n+1)').addClass('triggerMarginIE8');
},
failure: function(data){
console.log('FAIL');
}
});

关于javascript - AJAX 调用在 ipad 上不触发但在桌面上正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21016896/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com