如何循环这个JSON?我尝试了以下js,但它给出了我在下面提到的错误

时间:2015-02-01 17:11:35

标签: json



function searchMarks(srchMarksFrom,srchMarksTo){
	
	alert("search marks called: "+srchMarksFrom+ " "+srchMarksTo);
	
	$.ajax({
		type:"GET",
		url:"searchForMarks.htm",
		data: {
			"srchMarksFrom" : srchMarksFrom,
			"srchMarksTo": srchMarksTo
		},
		success:function(data){
			console.log(data);
			
		$.each(data,function(i,value){

			alert(studOnMarks.i.id);
		});
			
		},
		error: function(){
			alert("ajax failure");
		},	
	});
	
	
	
}//end of search me

this is the json response

{
  "studOnMarks": [
    {
      "id": 1,
      "name": "Rajan",
      "tenthmarks": 70,
      "dob": "1990-01-17",
      "phone": 9743473763
    },
    {
      "id": 2,
      "name": "subhasish",
      "tenthmarks": 78,
      "dob": "1989-06-19",
      "phone": 9743473763
    },
    {
      "id": 3,
      "name": "ani",
      "tenthmarks": 90,
      "dob": "1991-12-20",
      "phone": 9743473763
    }
  ]
}




我需要遍历这个json响应。我尝试了上面的js,但它给出了: 未捕获的TypeError:无法在'中使用'运营商搜索' 252'在{" studOnMarks":[{" id":1," name":" Rajan"," tenthmarks" :70," DOB":" 1990年1月17日""电话":9743473763},{" ID":2,& #34;名称":" subhasish"" tenthmarks":78," DOB":" 1989年6月19日&#34 ;, "电话":9743473763},{" ID":3,"名称":" ANI"" tenthmarks" :90" DOB":" 1991年12月20日""电话":9743473763}]} 我需要访问每个id,名称等。请帮忙

0 个答案:

没有答案