我的 ajax 调用成功地从数据库返回数据,但我无法弄清楚如何解析 json 并正确显示它。这是我的ajax调用:
$('#cardText').change(function(){
if($('#cardText').val().trim().length == 9)
{
$.ajax({
url: 'components/Person.cfc',
//GET method is used
type: "POST",
//pass the data
data: {
method: "getGroup",
uid: $('#cardText').val(),
},
datType: "json",
success: function(response) {
var resp = $.trim(response);
$('#form_result').html(resp);
},
error: function(jqXHR, exception) {
if (jqXHR.status === 0) {
alert('Not connect.\n Verify Network.');
} else if (jqXHR.status == 404) {
alert('Requested page not found. [404]');
} else if (jqXHR.status == 500) {
alert('Internal Server Error [500].');
} else if (exception === 'parsererror') {
alert('Requested JSON parse failed.');
} else if (exception === 'timeout') {
alert('Time out error.');
} else if (exception === 'abort') {
alert('Ajax request aborted.');
} else {
alert('Uncaught Error.\n' + jqXHR.responseText);
}
}
});
}
});
并将以下内容返回到 (div id="form_result") 但我不知道现在如何处理数据以正确显示它:
{"COLUMNS":["PLAN","NAME","ID","ISSUE","TYPE","LASTUSED","BALANCE"],"DATA":[["DINING STAFF CAFE 1919 ","YOUNG, MARIA ",8.03976343E8,"2001-04-02",2.0,"2012-01-27",1]]}
任何帮助,将不胜感激!杰拉德