首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Ajax >

jquery ajax的浏览器兼容有关问题 大神

2013-02-24 
jqueryajax的浏览器兼容问题大神求救啊jquery用的是jquery-1.7.1.min.jsfunction delete_article(id){$.po

jquery ajax的浏览器兼容问题 大神求救啊
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中 去服务器端调用代码  获取数据,但是就是不能正常进入 接下去的操作
[解决办法]
用$.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("删除失败");
        }
    });*/
}

热点排行