document.getElementById('channels').innerHTML = '<li><a onClick="loadChannel('+channelArray[i]+')"><h4>'+memberArray[i]+'</h4><p>Member</p></a></li>';
返回:
Uncaught SyntaxError: missing ) after argument list
谁能告诉我哪里出错?
以下是整个代码段:
$(document).on("pageinit", "#vendorMessages", function() {
var channelArray = new Array();
var memberArray = new Array();
pubnub.subscribe(
{
channelGroup: getChannelGroup()
},
function (status, response) {
alert("test");
console.log(status, response);
}
);
pubnub.channelGroups.listChannels(
{
channelGroup: getChannelGroup()
},
function (status, response) {
response.channels.forEach( function (channel) {
var channelFormatted = String(channel).split("_");
var channelMember = channelFormatted[1];
channelArray.push(String(channel));
memberArray.push(String(channelMember));
})
var i;
for (i=0; i<channelArray.length; i++) {
document.getElementById('channels').innerHTML = '<li><a onClick="loadChannel('+channelArray[i]+')"><h4>'+memberArray[i]+'</h4><p>Member</p></a></li>';
}
$("#channels").listview("refresh");
}
);
});