ajax 请求问题,能返回值但不能正确进入到success
$(function(){varuserurl="json.asp"$.ajax({type:"get",url:userurl,async:true,dataType:...
$(function (){ var userurl="json.asp" $.ajax({ type: "get", url:userurl, async: true, dataType: "json", success: function(data) { alert(data) }, error: function(xhr, textStatus, errorThrown){ alert("错误") } }) });
请问上面的请求代码,怎么都进不到成功里面呢,都是弹出错误
我用火狐的Firebug看到有返回值为
{"count":"2",items:[{"jt_id":"1","jt_name":"t1","jt_createtime":"2013-12-7 15:01:40","us":"a"},{"jt_id":"2","jt_name":"t2","jt_createtime":"2013-12-7 23:20:29","us":"b"}]}
$(function (){ var tt={"count":"2",items:[{"jt_id":"1","jt_name":"t1","jt_createtime":"2013-12-7 15:01:40","us":"a"},{"jt_id":"2","jt_name":"t2","jt_createtime":"2013-12-7 23:20:29","us":"b"}]} alert(tt.items[1].jt_id)//这样也能够正常得到值})
麻烦帮我看看是怎么回事呢,json格式也应该是正确的,为什么就进不到正确的地方,谢谢 展开
请问上面的请求代码,怎么都进不到成功里面呢,都是弹出错误
我用火狐的Firebug看到有返回值为
{"count":"2",items:[{"jt_id":"1","jt_name":"t1","jt_createtime":"2013-12-7 15:01:40","us":"a"},{"jt_id":"2","jt_name":"t2","jt_createtime":"2013-12-7 23:20:29","us":"b"}]}
$(function (){ var tt={"count":"2",items:[{"jt_id":"1","jt_name":"t1","jt_createtime":"2013-12-7 15:01:40","us":"a"},{"jt_id":"2","jt_name":"t2","jt_createtime":"2013-12-7 23:20:29","us":"b"}]} alert(tt.items[1].jt_id)//这样也能够正常得到值})
麻烦帮我看看是怎么回事呢,json格式也应该是正确的,为什么就进不到正确的地方,谢谢 展开
2个回答
展开全部
{
"count": "2",
items: [{ // 给items加双引号试试,JSON格式非常严格的
"jt_id": "1",
"jt_name": "t1",
"jt_createtime": "2013-12-7 15:01:40",
"us": "a"
}, {
"jt_id": "2",
"jt_name": "t2",
"jt_createtime": "2013-12-7 23:20:29",
"us": "b"
}]
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询