main.js 464 B

12345678910111213141516171819202122
  1. $(document).ready(function(){
  2. });
  3. function change_gpio_state(pin,element){
  4. state = $(element).hasClass('gpio_state_on')? 0:1;
  5. $(element).attr('class','gpio_state_waiting');
  6. $.ajax({
  7. url: "action.php",
  8. type: "POST",
  9. data: {action:'CHANGE_GPIO_STATE',pin:pin,state:state},
  10. success:function(response){
  11. if(state){
  12. $(element).attr('class','gpio_state_on');
  13. }else{
  14. $(element).attr('class','gpio_state_off');
  15. }
  16. }
  17. });
  18. }