How to execute a function in ajax when opening the page?

2

I have the following function in Ajax:

 $.ajax({
    type: "POST",
    url: "tra.php",
    data: {},
    dataType: 'json',
    suceess: function(Last)
    {
         line.originalData[0].push(Last);
         line.originalData[0].shift();

         RGraph.SVG.redraw();

    }
        });
    setTimeout(function () { update() }, 50);
}

 update();

However, the update () function is not starting, how do I make it work?

    
asked by anonymous 31.10.2017 / 23:49

2 answers

1

Try this:

$.ajax({
type: "POST",
url: "tra.php",
data: {},
dataType: 'json',
success: function(Last)
{
     line.originalData[0].push(Last);
     line.originalData[0].shift();

     RGraph.SVG.redraw();
     setTimeout(function () { update() }, 50);
}
    });

}

update();
    
01.11.2017 / 00:26
0

The code snippet below is out of the success function, and the success function is spelled wrong.

setTimeout(function () { update() }, 50);}
    
01.11.2017 / 00:22