Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var status = $(this).prop("checked");
- var room_id = id;
- $.post('maintenanceControl.php', {action: status, id: room_id});
- <?php
- if (isset($_POST['action']) && !empty($_POST['action']) && isset($_POST['id']) && !empty($_POST['id'])) {
- $action = $_POST['action'];
- $id = $_POST['id'];
- if ($action) {
- return manageMaintenance($id, true);
- } else {
- return manageMaintenance($id, false);
- }
- }
- function manageMaintenance($room_id, $status)
- {
- $jsonString = file_get_contents('status.json');
- $data = json_decode($jsonString, true);
- foreach ($data['rooms'] as $key => $entry) {
- if ($key == $room_id) {
- $data[$key]['maintenance'] = $status;
- }
- }
- $newJsonString = json_encode($data);
- file_put_contents('status.json', $newJsonString);
- return true;
- }
- $.post( "test.php", function( data ) {
- alert(data);
- });
- <?php
- echo "test";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement