vendredi 24 avril 2015

PHP+JS application structure

I'm wondering how should i manage data in my application.

Currently it is like that:

A javascript script fires the post query that passes the{"init" : 1} once the page loads, then it fires the post query to the same file with {"update" : 1} every N seconds and prints the returning value to the page.

What i currently have (the code is approximate just to make it clear):

if(isset($_POST["init"])) {
    $a = new A();
    $a->set(5);
} elseif (isset($_POST["update"])) {
    $a->update(); 
    return $a->get();
} 

But this doesn't work because it says that there is no $a when I'm trying to update.

How can I manage this? And how should i manage this?




Aucun commentaire:

Enregistrer un commentaire