weixin_33736832 2016-11-14 18:23 采纳率: 0%
浏览 96

Safari中的Ajax调用错误

I running this script, in most browsers is working ok, but in safari mobile, ex.iphone 6s it doesn't return the results: This is my portion of code:

$('#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);
                }

            });
        });

How can i solve this? Thanks in advance

  • 写回答

0条回答 默认 最新

    报告相同问题?