任何人都可以告诉我这是什么,jquery已将我的输出结尾添加到“posts-container”以及如何修复它?它不是来自json所以问题是什么。代码在下面,输出在最后添加。
提前致谢。
$(document).ready(function(){
$('#waiting').show(500);
$('#message').hide(0);
$.ajax({
type: 'get',
url: 'http://domain.com/api/index.php/id/18271',
dataType: 'json',
data: 'apiKeytest=1',
success: function(r){
var output = '';
for (a in r.DATA) {
for (b in r.DATA[a]) {
if (typeof(r.DATA[a][b]) == 'object') {
for (c in r.DATA[a][b]) {
output += c + ' = ' + r.DATA[a][b][c] + '<br />';
}
}
else {
output += b + ' = ' + r.DATA[a][b] + '<br />';
}
}
}
jQuery('#posts-container').append(output);
},
error: function(XMLHttpRequest, textStatus, errorThrown){
$('#waiting').hide(500);
$('#message').removeClass().addClass('error').text('There was an error.').show(500);
}
});
return false;
});
输出结尾了
argumentNames = function () { var names = this.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].split(",").invoke("strip"); return names.length == 1 && !names[0] ? [] : names; }
bindAsEventListener = function () { var __method = this, args = $A(arguments), object = args.shift(); return function (event) {return __method.apply(object, [event || window.event].concat(args));}; }
curry = function () { if (!arguments.length) { return this; } var __method = this, args = $A(arguments); return function () {return __method.apply(this, args.concat($A(arguments)));}; }
delay = function () { var __method = this, args = $A(arguments), timeout = args.shift() * 1000; return window.setTimeout(function () {return __method.apply(__method, args);}, timeout); } etc............
json
{
"ERRORS": [],
"DATA": [
{
"itemActive": true,
"itemTxt": "test",
"itemID": "30d2f2c1-58ca-4b3d-b3e0-d284ae5b25ab",
"itemValidTo": "October, 19 2011 00:00:00",
"itemName": "test",
"itemCreated": "October, 03 2011 00:00:00",
"image": {
"imageCreated": "October, 05 2011 00:00:00",
"imageURL": "test.jpg",
"imageID": "bc869a94-fee5-4fc8-bd21-e2de2f020310"
},
"itembio": 53.0650849
}
],
"MESSAGES": [
{
"TOTAL": 1,
"CURRENTPAGE": 1,
"TOTALPAGES": 1
}
]
}
答案 0 :(得分:1)
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/hasOwnProperty
所以你可能正在使用一些库,或者你自己的代码扩展了原生对象。
Witch是输出中出现的函数。 (函数的toString为您提供代码)
你可以通过检查该属性是来自该对象还是来自该对象的原型来解决它。
if(obj.hasOwnProperty(key)) {
// you have a property from the object
}