我有以下代码:
var url = "/MyURL";
$.get(url, function (dataUrl) {
jQuery.ajax({
type: "GET",
url: "MyURL?PrjID="+ prjid +" ",
data: dataUrl,
headers: {
"Content-Type": "application/json"
},
dataType: "json",
crossDomain: true,
async: true
}).success(function (data, textStatus) {
console.log(data)
})
});
以下是从Web服务(MyURL)中检索到的结果,该结果是有效的JSON字符串
[{"ProteinID":"O15247","GeneName":"CLIC2"},
{"ProteinID":"O95833","GeneName":"CLIC3"},
{"ProteinID":"Q9Y696","GeneName":"CLIC4"},
{"ProteinID":"O15516","GeneName":"CLOCK"}]
但是,从JSON请求中检索到的实际objects
总是比实际数据少一个元素,更确切地说,总是跳过结果集的第一条记录。对于上面的示例,我得到的结果(来自控制台的日志)如下:
0: Object { ProteinID: "O95833", GeneName: "CLIC3" }
1: Object { ProteinID: "Q9Y696", GeneName: "CLIC4" }
2: Object { ProteinID: "O15516", GeneName: "CLOCK" }
你知道这里怎么了吗?预先感谢。