Wednesday, December 10, 2014

Converting data submitted in post to a json file at server


Updating dropdown list

[
Example of refreshing on change in drop down list
]
var select = registry.byId('visitorname');
                        select.on('change', function(evt) {
                        visitorformrefresh();
                        visitorpsyrefresh();

                        });
<select name=visitorname id=visitorname data-dojo-type="dijit/form/Select" autocomplete=true >
                                    <option value=Guru>Guru</option>
                                    <option value=Ravindra>Ravindra</option>
                                    <option value=Harsha>Harsha</option>

</select>

Converting data submitted in post to a json file at server

[

The data received in backend is assigned to array and stored in json file

Example

        $jsonprofile = json_encode($profile);

        file_put_contents('profile.json', $jsonprofile);
]

public function actionregister() {

        $name = "";

        $description = "";

 

        if (isset($_POST['name'])) {

            $name = $_POST['name'];

        }

        if (isset($_POST['description'])) {

            $description = $_POST['description'];

        }

 

        $profile = array(

             'name' => $name,

             'description' => $description,

        );

 

        $jsonprofile = json_encode($profile);
       file_put_contents('profile.json', $jsonprofile);
       $this->actionprocessowner();

        // echo "Data saved";

    }

 

No comments:

Post a Comment