在运行脚本时,在firebug中获取typeError:e未定义 [英] Getting typeError:e is undefined in firebug while running a script
问题描述
我无法弄清楚我的代码有什么问题。我从数据中获取数据,然后在框中显示该数据。
I am not able to figure out what is wrong with my code.I am getting data from post as an array and I am then displaying that data in box.
function worker() {
var a = $("#BeeperBox");
var delay =2000;
$.ajax({
url: '/index.php/admin/getLatest',
success: function(data) {
$.each(data.upda,function(i, v){
var out = v.name + v.mob ;
$('span.blueName').html(out);
$("#BeeperBox").show();
timerId = setTimeout(function () {
a.hide();
}, delay);
});
},
complete: function() {
// Schedule the next request when the current one's complete
setTimeout(worker, 50000);
}
});
}
当我运行时firebug显示错误:TypeError:e is undefined。 p>
When i run it firebug shows error: TypeError: e is undefined.
推荐答案
因为你发送的响应作为JSON ..它更好地指定你的 dataType
作为JSON(虽然如果没有指定,jQuery将尝试根据响应的MIME类型推断它
),以便您不必解析它manaully。 。我认为这里的问题是你没有解析你作为回应的json
since your sending the response as JSON.. its better to specify your dataType
as JSON (though If none is specified, jQuery will try to infer it based on the MIME type of the response
) so that you don't have to parse it manaully..i think the problem here is you havn't parsed the json that you got as response
试试这个
$.ajax({
url: '/index.php/admin/getLatest',
dataType: 'json',
success: function(data) {
$.each(data.upda,function(i, v){
var out = v.name + v.mob ;
......
},
这篇关于在运行脚本时,在firebug中获取typeError:e未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!