0
我为每个用户获取名称,并将该名称设置为该名称。我在这里设置图像的ID作为名称。然后在点击这些图像时,我将名称传递到显示使用该名称数据的history.php页面。但是现在在window.location订单项中未定义。这是做到这一点的正确方法还是存在其他标准方法?获取名称到历史页面
$.getJSON('rest.php/names', function(data) {
var items = [];
var recs = data.records;
for(var i=0; i<recs.length; i++){
items[i] = recs[i].name;
$('#theImg').append('<img id="' + items[i] + '"' + 'src="images/Arrow-Left.png" />');
$("img").click(function(){
window.location = 'history3.php?name=' + items[i];
});
}
});
不是你的问题的解决方案,但移动单击处理出来的for循环。你只需要绑定一次事件。 –