Home > Backend Development > PHP Tutorial > javascript - jq 中 $.post() 在IE中不能使用,其兼容性怎么解决!

javascript - jq 中 $.post() 在IE中不能使用,其兼容性怎么解决!

WBOY
Release: 2016-06-06 20:23:45
Original
1464 people have browsed it

<code> $.post("/dadashou/index.php/Companymanage/findBrand_ajax",{kw:$this.val().trim(),cache:new Date().getTime()},function(data){ 
        if(data!=0){
            $brandhidden.empty(); 
            var html=""; 
            for(var i=0;i<data.length html bid="'+data[i]['id']+'">'+data[i]['brand']+''+"\n"; 
            } 
            html+="<strong class="end"><span>   ----- 务必在下拉框中选择 -----</span></strong>"; 
            //把loading动态图替换成内容 
            $brandhidden.html(html); 
            $brandhidden.css({display:'block'});
        }else{
            $this.siblings('input[name="brands"]').val($this.val().trim());
            $this.siblings('.brandhidden').fadeOut('fast'); 
            $this.data('ok',true);
        }    
        return false;   
    },"json"); </data.length></code>
Copy after login
Copy after login

回复内容:

<code> $.post("/dadashou/index.php/Companymanage/findBrand_ajax",{kw:$this.val().trim(),cache:new Date().getTime()},function(data){ 
        if(data!=0){
            $brandhidden.empty(); 
            var html=""; 
            for(var i=0;i<data.length html bid="'+data[i]['id']+'">'+data[i]['brand']+''+"\n"; 
            } 
            html+="<strong class="end"><span>   ----- 务必在下拉框中选择 -----</span></strong>"; 
            //把loading动态图替换成内容 
            $brandhidden.html(html); 
            $brandhidden.css({display:'block'});
        }else{
            $this.siblings('input[name="brands"]').val($this.val().trim());
            $this.siblings('.brandhidden').fadeOut('fast'); 
            $this.data('ok',true);
        }    
        return false;   
    },"json"); </data.length></code>
Copy after login
Copy after login

$.post()是可以使用的,不能用的原因应该是你的jQuery的版本太高。

感觉是你的代码有误
jquery是帮你解决好兼容性问题的,所以用jquery一般不用考虑兼容性问题

$this.val().trim() 这句似乎可能有问题,jquery里一般用$.trim($this.val())这种形式

先检查下你的$this对象对不对。
实在不行使用$.ajax

<code>$.ajax({
  type: 'POST',
  url: url,
  data: data,
  success: success,
  dataType: dataType
});</code>
Copy after login

http://www.lxway.com/99016642.htm

使用1.xx版本的jQuery

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template