Getting typeError:e is undefined in firebug while running a script

12,467

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

try this

  $.ajax({
    url: '/index.php/admin/getLatest', 
    dataType: 'json',
    success: function(data) {
      $.each(data.upda,function(i, v){
      var out = v.name + v.mob ;
       ......
   },
Share:
12,467
RiderHood
Author by

RiderHood

Updated on June 04, 2022

Comments

  • RiderHood
    RiderHood about 2 years

    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);
            }
        });
    }
    

    When i run it firebug shows error: TypeError: e is undefined.