我正试图与穆斯塔奇一道列举并建造以下dle。 j)
$(function () {
var choices = { "users": [
{ "first_name": "Ryan",
"last_name": "Pays",
"pic_square": "/Global/profile/thumb/placeholder.jpg",
"product_name": "Merlin - the complete box set",
"product_picture": "/Global/products/full/box-set.jpg"
},
{ "first_name": "Eric",
"last_name": "Li Koo",
"pic_square": "/Global/profile/thumb/placeholder.jpg",
"product_name": "Merlin - Series 4 volume 1",
"product_picture": "/Global/products/full/box-set.jpg"
},
{ "first_name": "Abdul",
"last_name": "Raouf",
"pic_square": "/Global/profile/thumb/placeholder.jpg",
"product_name": "Merlin - the complete box set",
"product_picture": "/Global/products/full/box-set.jpg"
}]
};
$.getJSON("http://jsfiddle.net/echo/jsonp/?callback=?", choices, function (data) {
console.log(data);
var template = "<ul>{{#users}}" +
"<li>" +
"<p><strong>{{first_name}} {{last_name}}</strong> likes {{product_name}}</p>" +
"</li>" +
"{{/users}}</ul>",
html = Mustache.to_html(template, data);
$( .wrapper ).html(html);
});
});
Example here -> 。
它正确地记录了JSON对青.的反应,但似乎未能建立模板。 如果只是把一个用户带给JSONP背书,那就行了罚款。
提前感谢。