我们的一位工程师刚把他的iPad带到我面前,并展示了一个不在我们网站上工作的功能.这适用于Chrome和Firefox,但它无法在iPhone或iPad上运行.这是3个选择框,当您单击第一个中的值时,它会运行ajax并填充第二个选择框.
这是在iOS中不起作用的功能.
我们有点难以开始测试这个.任何人都可以提供一些建议,从哪里开始调试这个或者你能看到我们做错了吗?
$().ready(function () {
$('.vehicle-search .make').bind('click', function (e) {
var makeId = $(e.target).val();
var container = $(e.target).parent('.vehicle-search');
if (parseInt(makeId) > 0) {
$.ajax({
url: site.internal.url + '/lib/ajax/vehicle/make/getModelList.php',
type: 'post',
dataType: 'json',
success: function (r) {
if (r.length > 0) {
$('.vehicle-search > .model').html('');
$('.vehicle-search > .year').html('');
var html = '';
for (var i = 0; i < r.length; i++) {
html += "<option value='"+r[i].id+"'>"+r[i].name+"</option>";
}
$('.vehicle-search > .model').html(html);
} else {
alert('We did not find any models for this make');
}
},
error: function () {
alert('Unable to process your request, ajax file not found');
return false;
},
data: {
makeId: makeId
}
});
} else {
$('.vehicle-search > .model').html('');
$('.vehicle-search > .year').html('');
}
});
........
解决方法:
绑定到< select>的更改事件而不是点击事件.
此外,iPad应为enable the Developer Console,以便您可以看到可能发生或可能不发生的任何JS错误.
在将来,将事件处理程序中的console.log语句作为完整性检查放入,以查看它们是否正在被调用,以及它们是否要确定它们在何时失败.
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!