スタックオーバーフローからいくつかの回答を試しましたが、私からは機能しませんでした...jqueryでasmxWebサービスを呼び出していますコードは次のとおりです
<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"}]
データを解析して表示する方法を知りたい