jquery ajax的浏览器兼容问题 大神求救啊

h420943302 2013-01-30 11:22:11
jquery用的是jquery-1.7.1.min.js
function delete_article(id){	
$.post('__URL__/delete',{article_id:id},function(val){
if(val==1){
$('#count').html($('#count').html()-1);
$('#article'+id).remove();
}else if(val==2){
alert("删除失败");
}
});
}

这段在ie和火狐都能正常 ,但在 google浏览器就不正常,服务器端能正常返回数据
function edit_article(n,id){	
switch(n){
case "1":
$.getJSON("__URL__/shenhe",{article_id:id},function(json){
if(json.status==1){
var html="<img src=\"{:aout_image(2)}\" onclick=\"edit_article('2','"+id+"');\" title=\"{:aout(2)}\" />";
$("#edit"+id).html(html);
}else if(json.status==5){
alert(json.info);
var html="<img src=\"{:aout_image("+json.data+")}\" onclick=\"edit_article('"+json.data+"','"+id+"');\" title=\"{:aout("+json.data+")}\" />";
$("#edit"+id).html(html);
}else{
//alert(json.info);
alert(json.info);
}
});
break;
case "2":
if({:getuserinfo("manage")}=={:C("AUDITOR")}){
return false;
}
$.getJSON("__URL__/caina",{article_id:id},function(json){
if(json.status==1){
var html="<img src=\"{:aout_image(3)}\" onclick=\"edit_article('3','"+id+"');\" title=\"{:aout(3)}\" />";
$("#edit"+id).html(html);
}else{
alert(json.info);
}

});
break;
}
}
function yuan_article(id){
//alert("正在检测,请稍后...");
showd();
$.getJSON("__URL__/yuanchuang",{article_id:id},function(json){
hiddend();
if(json.status==1){
alert(json.info);
}else{
$('#count').html($('#count').html()-1);
$('#article'+id).remove();
alert(json.info);
}
});
}

这个就是只有火狐能正常反应,ie和google浏览器 不行,也是服务器端能正常返回数据
都是 能正常进入ajax中 去服务器端调用代码 获取数据,但是就是不能正常进入 接下去的操作
...全文
183 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
h420943302 2013-01-30
  • 打赏
  • 举报
回复
返回的格式为 {"status":1,"info":"\u5ba1\u6838\u6210\u529f","data":0}
MakeUrChois 2013-01-30
  • 打赏
  • 举报
回复
Chrome什么版本? 第二个问题先检查一下json的格式是不是正确。
奇乐二二二 2013-01-30
  • 打赏
  • 举报
回复
代码问题,鉴定完毕
Go 旅城通票 2013-01-30
  • 打赏
  • 举报
回复
用$.ajax发送请求,配置success/error回调看执行到error没,执行到error输出返回了什么内容
function delete_article(id){   
$.ajax({type:'POST',
url:'__URL__/delete',
data:{article_id:id},
success:function(val){
        if(val==1){
            $('#count').html($('#count').html()-1);
            $('#article'+id).remove();
        }else if(val==2){
            alert("删除失败");
        }
},
error:function(xhr){alert('错误\n+'+xhr.status+'\n'+xhr.responseText)}/////
});/*
    $.post('__URL__/delete',{article_id:id},function(val){
        if(val==1){
            $('#count').html($('#count').html()-1);
            $('#article'+id).remove();
        }else if(val==2){
            alert("删除失败");
        }
    });*/
}
h420943302 2013-01-30
  • 打赏
  • 举报
回复
简而言之,就是 在火狐一切正常 在其他浏览器就会出现 没法进入ajax回调函数的问题

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧