Eclipse Switch Button value Json url Read/Write

1.5k Views Asked by At
{'outlet1':'on' , 'outlet2':'off' , 'outlet3':'on'}

[http://192.168.2.200:5555/getJsonData.json][1] in "Outlet1" provision on the value read out from the android buttons in the switch to the "ON" and "OFF" values ​​can be inflicted.

enter image description here

3

There are 3 best solutions below

1
Ahmad Dwaik 'Warlock' On

You can read json easily follow this tutorial when its come to writing it's easy to generate and upload json but you need to commit it from serverside using a simple service

0
Selçuk On

I also want to do the following operation android :

<script> function updateControls() { $.getJSON('/status.json', function (json) { $.each(json, function (key, value) { $('#' + key).val(value).slider('refresh'); }); }); } $('select').on('change', function (event) { element = event.target.id; if (element.substr(0, 6) == 'outlet') { eleid = element.substr(6, 2); } else { eleid = 0; } command = event.target.value; $.get('/cmd', { 'eleid': eleid, 'cmd': command }); }); $(document).ready(function () { updateControls(); }); </script>

0
Selçuk On

Json managed to read. But Switch ON or OFF manually when I want to send a POST.

Switch = ON  [POST value : http://192.168.2.200/State?eleid=10&cmd=on  ]
Switch = OFF [POST value : http://192.168.2.200/State?eleid=10&cmd=off ]