之前都是正确的,前几天服务器被黑过,MYSQL数据库直接被删除,我已经将数据库恢复。但现在这段程序就报错,找不到原因,很是郁闷,请大神们帮帮我。
先贴出弹出的错误:
1 异步调用返回失败,XMLHttpResponse.readyState:4
2 异步调用返回失败,XMLHttpResponse.status:200
3 异步调用返回失败,textStatus:parsererror
4 异步调用返回失败,errorThrown:SyntaxError: Unexpected token in JSON at position 0
下面贴出前台调用方法。
$(".btn_use").click(function(){
presentid=$(this).data("presentid");
var _this = $(this);
if(!$(this).hasClass("readonly")){
$.ajax({
async:false,
url:'{lnmj|:U("Orderbranch/get_goods_present")}',
type:'post',
dataType:'json',
data:{"presentid":presentid,"wecha_id":"{lnmj|$_GET['wecha_id']}"},
error:function(XMLHttpResponse, textStatus, errorThrown){
//$.jBox.tip( '未使用' ,'error');
//result = true;
var ts = "1 异步调用返回失败,XMLHttpResponse.readyState:"+XMLHttpResponse.readyState;
ts = ts + "2 异步调用返回失败,XMLHttpResponse.status:"+XMLHttpResponse.status;
ts = ts + "3 异步调用返回失败,textStatus:"+textStatus;
ts = ts + "4 异步调用返回失败,errorThrown:"+errorThrown;
alert(ts);
},
success:function(result){
var specifications= result.specifications;
var goods=result.goods;
if(goods.present_goods_id>0){
if(specifications){
var html_c="<div style='padding:10px;' >";
$.each(specifications,function(index,value){
html_c+="<input type='radio' name='specifications_desc' stock="+value.stock+" value='"+value.code+"' /><span>"+value.specifications+"</span> ";
});
html_c+="</div>";
$.jBox.prompt(html_c, "请选择商品型号","info", {submit:function (v, h, f) {
var specifications=$(h).find("input[name='specifications_desc']:checked").next("span").text();
var stock=$(h).find("input[name='specifications_desc']:checked").attr("stock");
if(!specifications){
alert("请选择商品型号");
return false;
}
if(parseInt(stock)==0){
alert("该型号无库存");
return false;
}
comfired_use(_this,specifications);
}
});
}else{
if(parseInt(goods.stock)==0){
alert("该商品无库存");
return false;
}
comfired_use(_this,null);
}
}else{
comfired_use(_this,null);
}
}
})
}
});
下面是后台方法echo json_encode(array('goods'=>$goods,'specifications'=>$specifications));的返回值
{"goods":{"id":"4008","goodsid":"4124","presentname":"\uff08\u65b0\uff09\u51dd\u7f8e.\u8d44\u6df1\u6d17\u5439 28\u5143","num":"10","address":"\u4e1c\u5761\u533a\u6e56\u6ee8\u8def122\u53f7\/\u4e1c\u5761\u533a\u82cf\u6e90\u8def412\u53f7\/\u5f6d\u5c71\u533a\u6ee8\u6c5f\u5e97140\u53f7","password":"1314","descript":"","addtime":"1535694957","endtime":"0","statetime":"1549987200","state":"0","information":"<p style=\"white-space:normal;\">\n\t<img src=\"http:\/\/mall.lnmjsc.com\/mall\/Uploads\/image\/20181123\/5bf771a00176c.jpg\" alt=\"\" \/> \n<\/p>\n<p style=\"white-space:normal;\">\n\t<img src=\"http:\/\/mall.lnmjsc.com\/mall\/Uploads\/image\/20181123\/5bf771a0686c1.jpg\" alt=\"\" \/> \n<\/p>\n<p style=\"white-space:normal;\">\n\t<img src=\"http:\/\/mall.lnmjsc.com\/mall\/Uploads\/image\/20181123\/5bf771a110650.jpg\" alt=\"\" \/> \n<\/p>\n<p style=\"white-space:normal;\">\n\t<img src=\"http:\/\/mall.lnmjsc.com\/mall\/Uploads\/image\/20181123\/5bf771a1a4eac.jpg\" alt=\"\" \/> \n<\/p>\n<p style=\"white-space:normal;\">\n\t<img src=\"http:\/\/mall.lnmjsc.com\/mall\/Uploads\/image\/20181123\/5bf771a22aa8a.jpg\" alt=\"\" \/> \n<\/p>\n<p style=\"white-space:normal;\">\n\t<img src=\"http:\/\/mall.lnmjsc.com\/mall\/Uploads\/image\/20181123\/5bf771a29ce38.jpg\" alt=\"\" \/> \n<\/p>\n<p style=\"white-space:normal;\">\n\t<img src=\"http:\/\/mall.lnmjsc.com\/mall\/Uploads\/image\/20181123\/5bf771a30f9ed.jpg\" alt=\"\" \/> \n<\/p>\n<p style=\"white-space:normal;\">\n\t<img src=\"http:\/\/mall.lnmjsc.com\/mall\/Uploads\/image\/20181123\/5bf771a3a7d88.jpg\" alt=\"\" \/> \n<\/p>\n<p style=\"white-space:normal;\">\n\t<br \/>\n<\/p>\n<p style=\"white-space:normal;\">\n\t<br \/>\n<\/p>","ifday":"0","day":"0","sort":"0","islottery":"0","pic":"\/mall\/Uploads\/image\/20180807\/5b6944adf2302.jpg","link_des":"","title":"","present_goods_id":"4008","price":"0.00","performance":"100.00","code":"CMKCHLB01_SYS2046","class":"5","GoodsName":"\uff08\u65b0\uff09\u51dd\u7f8e.\u8d44\u6df1\u6d17\u5439 28\u5143","Type":"279","Color":"","specifications":"","NetContent":"","OriginalPrice":"28.00","PresentPrice":"28.00","Rebate":"","thumb":"","Introduction":"","Information":"","content":"","updatetime":"1553667001","Sales_volume":"0","Real_sales":"2305","browsing_number":"0","browsing_people":"0","homepage":"0","pinpai":"462","pinlei":"0","ifoverseas":"0","country":"0","discount":"95.00","Stock":"11621","stopnum":"0","ifstop":"0","specifications_desc":"","kind":"64","userid":null,"ifself":"0","fans":"0","totalnum":"0","zeroprice":"0.00","fansbargain":"0.00","nore_time":"6","isvirtual":"0","warning":"","virtualstock":"100","isshow_discount":"0","delivery_method":"1","branch":"1,57,68","levelopen":"","ispresell":"0","rebate_on":"0","rebate_a":"0.00","rebate_b":"0.00","rebate_c":"0.00","nopaytype":"","province":"0","city":"0","town":"0","unionid":"0","dividends":"0.00","dividends_branchman":"0.00","purchase":"0","codebuy":"0","station":"","description":"","present_count":"0","isgive":"1","packet_price":"0.00","packet_title":null,"ispacket":"0","isphoto":"0","level_price_1":"0.00","level_price_2":"0.00","level_price_3":"0.00","level_price_4":"0.00","level_price_5":"0.00","level_price_6":"0.00","level_price_7":"0.00","level_price_8":"0.00","integral_ratio_level_1":"0.00","integral_ratio_level_2":"0.00","integral_ratio_level_3":"0.00","integral_ratio_level_4":"0.00","integral_ratio_level_5":"0.00","integral_ratio_level_6":"0.00","integral_ratio_level_7":"0.00","integral_ratio_level_8":"0.00","isintegral":"0","specifications_stock":"","activ_pic":"","activ_discount":"0.00","activ_presentprice":"0.00","performance_price":"28.00","istuoke":"0","postype":"2","IsMaker":"0","stock":444},"specifications":null}