变量 $x10Device 在 if 语句中说 undefined 为什么?在其余的功能中它有一个价值,我如何让它保持它的价值。
$("button.checkStatus").click(function () {
//This Ajax checks the current on/off status of the passed X10 code
$('.checkStatus').each(function (i, obj) {
$x10Device = $(this).data("x10");
//var data = "url=http://192.168.0.34:81/tenHsServer/tenHsServer.aspx?t=ab&f=DeviceStatus&d=C5" //& $x10Device ; //this is passed in the device toggle
var data = "url=http://192.168.0.34:81/tenHsServer/tenHsServer.aspx?t=ab&f=DeviceStatus&d=" + $x10Device; //this is passed in the device toggle
$.ajax({
url: "urlencode.php",
data: data,
type: "POST",
success: function (data) {
myd = $('<span />').html(data).find("#Result").text();
var Nmyd = myd.charAt(3);
if (Nmyd == '2') {
$($x10Devic).data('src', 'lightbulbon.png')
} else {
$('img').attr('src', 'lightbulboff.png')
};
},
error: function (request, status, error) {
alert(request.responseText);
}
});
});
});