Mav*_*ven 1 javascript asp.net-mvc jquery json
我正在使用jQuery .load()函数从服务器加载结果并将其附加到我的html中:
$("#content").load('Get/Information?class=Arts&min=1',
function (responseText, textStatus, XMLHttpRequest) {
console.log(responseText);
// parseJSON(responseText);
});
Run Code Online (Sandbox Code Playgroud)
在我的控制器中,我尝试将我的锯齿状数组从模型转换为json对象,然后将其发送到客户端:
public JsonResult GetInformation(string class, int min){
var stdObj = new Student();
string[][] information = stdObj.GetInformation(class, min);
return Json(information, JsonRequestBehavior.AllowGet);
}
Run Code Online (Sandbox Code Playgroud)
在此之后,当我检查响应时,console.log(responseText);
我有一个类似jSon的字符串,格式如下:
[
["93","Title-1","http://stackoverflow.com"],
["92"," Title-2","http://stackoverflow.com"],
["90"," Title-3","http://stackoverflow.com"],
["89"," Title-4","http://stackoverflow.com"],
["89"," Title-5","http://stackoverflow.com"],
null,null,null,null,null]
Run Code Online (Sandbox Code Playgroud)
我不确定这是否是一个正确的jSon,就像我学到的东西jSon的名字:值对,但这里只有值,考虑到这个如何读取这个字符串/数组并按以下方式打印:
这只是我需要如何处理它的表示(伪代码):
for(int 1=0; i<response.length();i++){
$("#content").html('<h1>'+i.Id+'</h1>'+'<p>'+i.Title+'</p>'+'<span>'+i.url+'</span>')
.slideDown('slow');
// $("#content").html('<h1>39</h1>'+'<p>Title-1</p>'+'<span>http://stackoverflow.com</span>');
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
50370 次 |
| 最近记录: |