推广 热搜: 劳务  海南  2024  合同  江苏  云南  劳务系统  2023  劳务派遣管理软件  劳务派遣管理系统 

ie6下jsonp返回失效问题

   2024-06-10 200
核心提示:p问题描述:在ie6下用jsop,用fillder查看的确是已经发送成功并且已经有返回了,状态是成功的。但是成功函数就是不执行。codecla
<p>问题描述:在ie6下用jsop,用fillder查看的确是已经发送成功并且已经有返回了,状态是成功的。但是成功函数就是不执行。<codeclass="lang-javascript">(function($){</p><p>$.fn.plugin_name=function(){</p><p>varmethods={</p><p>getSomeThing:function(callback){</p><p>$.ajax({</p><p>type:'GET',</p><p>dataType:'jsonp',</p><p>url:'http://thirdparty.com/get',</p><p>success:function(response){</p><p>callback(response);</p><p>}</p><p>});</p><p>},</p><p>getDetail:function(callback){</p><p>$.ajax({</p><p>type:'GET',</p><p>dataType:'jsonp',</p><p>url:'http://thirdparty.com/getdetail',</p><p>data:{id:1},</p><p>success:function(response){</p><p>//thiscodeblockhasneverexecutedinIE6</p><p>},</p><p>error:function(request,status,error){</p><p>alert(request.statusText);//iget"success"inIE6</p><p>alert(status);//iget"parseerror"inIE6</p><p>alert(error.error);//iget[objectError]inIE6</p><p>}</p><p>});</p><p>}</p><p>};</p><p></p><p>returnthis.each(function(){</p><p>varself=$(this);</p><p>methods.getSomeThing(function(response){//workOK</p><p>//processresponse</p><p>self.html(response.html);//workOK</p><p></p><p>self.append('&lt;ahref="javascript:;"id="linkDetail"&gt;ViewDetail&lt;/a&gt;');</p><p></p><p>self.on('click','#linkDetail',function(){</p><p>//imakeanajaxrequesthere</p><p>methods.getDetail(function(response){</p><p>//failed!!</p><p>});</p><p>});</p><p></p><p>});</p><p>});</p><p>}</p><p></code></p><p>解决方法:在元素click的时候写下event.preventDefault();</p><p>例如:<codeclass="lang-javascript">self.on('click','#linkDetail',function(event){</p><p>event.preventDefault();</p><p>//imakeanajaxrequesthere</p><p>methods.getDetail(function(response){</p><p>//failed!!</p><p>});</p><p>});</p><p></code></p><p>ps:ie6下会因为event.preventDefault();报错,只要写成event.returnValue=false;就好。本文由免费劳务派遣系统软件系统起航劳务派遣系统原创,转载请注明出处。</p>
 
反对 0举报 0 收藏 0 打赏 0评论 0
 
更多>同类资讯
推荐图文
推荐资讯
点击排行
网站首页  |  关于我们  |  联系方式  |  使用协议  |  版权隐私  |  网站地图  |  排名推广  |  广告服务  |  积分换礼  |  网站留言  |  RSS订阅  |  违规举报  |  粤ICP备18079127号  |  粤ICP备18079127号