我正在尝试将 jQuery 程序从 1.8 版升级到 1.9 版。在早期版本中 .live() 方法工作正常,但新的 .on() 方法不能。发送到检索数据的 Web 服务的参数“KenID”是“未定义的”,因此不返回任何数据。此参数设置为 sessionStorage 项,所以我猜 .on() 方法无权访问它。我应该采取哪些步骤才能使其发挥作用?
工作程序(jQuery 1.8):
$('#AddrList').live('pagebeforeshow', function (e, data)
{
alert(sessionStorage.KenID); // shows correct KenID
$.ajax({
// extracting required data by sending KenID to the web service
});
});
不工作的程序(jQuery 1.9):
$(document).on('pagebeforeshow', '#AddrList', function (e, data)
{
alert(sessionStorage.KenID); // shows "undefined"
$.ajax({
// extracting required data by sending KenID to the web service
});
});
谢谢你,雅克