我正在尝试从 twitter 的 JSONP 结果中返回一些数据。然后,我尝试自定义响应并添加我自己的“ID”参数,以便在将其转换回 JSON 时将其用作键/值对中的键。对于为什么 jQuery prepend 函数不适用于这种情况,我有点困惑。
这是我正在使用的一小段代码
$.getJSON('http://api.twitter.com/1/statuses/user_timeline.json?user_name=twitterapi&callback=?', function(data) {
$.each(data, function(i) {
$(data[i].id_str).prepend("id:"); //foobar, doesn't prepend anything
});
PS。我知道这不是我最终想要的格式化结果,但问题是关于前置。