Need help understanding how to get this to work.
Given:
var data = {"time":"20151206212722","Irms":"2940"}
and:
<script type="text/javascript">
$.ajaxSetup({
cache: false
});
setInterval(function() {
$(function() {
$.get("data-upload_emon.txt", function(data, textStatus) {
console.log(data);
$.each(data, function(key, value) {
console.log(key);
console.log(value);
Irms = value.Irms
console.log(Irms);
$("#ajax1").fadeOut(200, function() {
$("#ajax1").html(
time
).fadeIn(2);
}),
$("#ajax2").fadeOut(200, function() {
$("#ajax2").html(
Irms
).fadeIn(2);
})
});
},
"json"
);
})
}, 10000);
</script>
Why is var Irms undefined? First three console logs return what is expected. Console.log(Irms) returns as "undefined"
Thank you!! This is driving me crazy.
jQuery.getJsoninstead of getIrmsbefore assigning anything to it, something likevar Irms = value.Irms console.log(Irms);value?