我有一个数组:
var sampleitems =[];
我从返回值的 url 获取 json 数据
WinJS.xhr({
type: "GET",
url: "http://some_webpage.php",
}).then(function (success) {
// DYNAMICALLY PUSH CONTENTS TO ARRAY 'sampleitems'
},
function (error) {
document.getElementById("check").innerText = "vada pochu";
}
我需要数组看起来像:
var sampleitems = [
{ key: "group1", title: "Group Title: 1", subtitle: "Group Subtitle: 1", backgroundImage: darkGray, description: groupDescription } ];
如何动态地向示例项添加值以及我的 PHP 页面应如何以哪种格式返回 JSON?