我有下面的腳本不工作100%,則返回20不確定的,在這些不確定之間的某個地方,它會返回FULL_NAME:JSON數據可能不正確格式化
function get_staff_details(phrase) {
$.ajax({
url: 'get_staff_details.aspx?rand=' + Math.random(),
type: 'POST',
dataType: 'json',
data: { strPhrase:phrase },
error: function(xhr, status, error) {
console.log(status);
console.log(xhr.responseText);
},
success: function(results) {
var itemList = results;
var buildHTML = [];
for (var i = 0; i < itemList.length; i++) {
buildHTML.push('<div class="container"><a href="#" class="title" target="_blank">' + itemList[i].full_name + '</a></div>');
}
$('.portlet-content').empty().append(buildHTML.join('<hr />'))
}
});
}
我認爲它有與json數據有關,可能沒有正確格式化來循環使用它?
[
{
"image": "http://intranet/images/jb.jpg"
},
{
"position": "Marketing Manager"
},
{
"cms_initials": "JB"
},
{
"department_name": "Marketing"
},
{
"secretary": ""
},
{
"fee_earner": ""
},
{
"mon_from": "08:30"
},
{
"mon_to": "17:00"
},
{
"tue_from": "08:30"
},
{
"tue_to": "17:00"
},
{
"wed_from": "08:30"
},
{
"wed_to": "17:00"
},
{
"thu_from": "08:30"
},
{
"thu_to": "17:00"
},
{
"fri_from": "08:30"
},
{
"fri_to": "17:00"
},
{
"full_name": "Jo Bloggs"
},
{
"extension": "0000"
},
{
"direct_line_number": "0000000000"
},
{
"blackberry_number": ""
}
]