我运行这个脚本,在大多数浏览器中工作正常,但在safari mobile,ex.iphone 6s中它不会返回结果: 这是我的代码部分:
$('#billing\\:postcode').on('keydown', function () {
$('#billing\\:postcode').bind('keydown',function(e){
var length = $(this).val().length;
var keyCode = e.keyCode;
var $this = $(this);
clearTimeout(_timeout);
if(length == 3 || keyCode == 9 || keyCode == 13) {
_timeout = setTimeout(function () {
//$this.addClass('loading');
$.ajax({
url: '/fotterajax/city/index/cp/'+$this.val()+'/',
dataType: 'json',
beforeSend:function(){
$('#billing\\:postcode').addClass('loading');
},
})
.success(function (json, status) {
_billingRegionInput.hide();
var data = '<option value=""></option>';
if (json.length > 0) {
CityDropdown.succesMsg($this);
_billingRegionInput.val(json[0].province_id);
_billingRegionInput.next().text(json[0].province);
$.each(json, function (k,v) {
data += '<option value="'+v.city+'">'+v.city+'</option>';
});
console.log(status);
} else {
CityDropdown.errorMsg($this);
_billingRegionInput.val('');
_billingRegionInput.next().text('');
console.log('error');
}
_billingCityInput.val('');
_billingCityDropdown.html(data);
if (json.length === 1) {
_billingCityDropdown.val($('option:last', _billingCityDropdown).attr('value')).change();
}
$this.removeClass('loading');
});
}, 1);
}
});
});
我该如何解决这个问题?提前致谢