我尝试了堆栈溢出的一些答案,但它对我不起作用......我在 jquery 中调用 asmx Web 服务这是代码
<script type="text/javascript">
$(document).ready(function () {
$.ajax({
type: "POST",
url: "http://localhost:4845/service.asmx/HelloWorld",
cache: false,
contentType: "application/json; charset=utf-8",
data: "{}",
dataType: "json",
success: handleHtml,
error: ajaxFailed
});
});
function handleHtml(data, status) {
debugger
//var myObject = jQuery.parseJSON(data);
for (var i = 0; i < data.d.length; i++) {
alert(data.d[1].date);
}
}
function ajaxFailed(xmlRequest) {
alert(xmlRequest.status + ' \n\r ' +
xmlRequest.statusText + '\n\r' +
xmlRequest.responseText);
}
</script>
当我解析它返回的 null 并且如果我不解析它的显示身份不明的对象.. 这是我的 json 字符串
[{"name":"jef","date":"10/12/2012","ID":0,"description":"test1"},
{"name":"sam","date":"18/12/2012","ID":0,"description":"test2"},
{"name":"dan","date":"1/1/2013","ID":0,"description":"test3"},
{"name":"san","date":"1/2/2013","ID":0,"description":"test4"}]
我想知道如何解析数据并显示