$.ajax方法获取json数据,解析不出来json中数据
小圈09 2016-08-05 07:13:49 代码:
function loadData(pars) {
$.ajax({
url: "http://192.168.1.9:71/WebService.asmx/v_getQuesInfoDet?jsoncallback=?",
dataType:"json",
data: pars,
cache: false,
success:OnSuccess,
error:OnError
});
}
function OnSuccess(json) {
document.getElementById("contentIf").innerText = json.result;
var defaultData = json.result;
alert(defaultData[0].GID);
alert(defaultData[0].Stem);
}
获取到异步数据
[{"GID":"d51fadd7f64c47a29afbc05472facaa7","ItemTypeID":null,"Stem":"<p>
Writing <br />
Directions: For this part, you are allowed 30 minutes to write an essay commenting on the saying ‘Learning is a daily experience and a lifetime mission.” You can cite examples to illustrate the importance of lifelong learning. You should write at least 120 words but no more than 180 words.</p>"}]
但是alert弹出:undefined