jquery - Ajax set variables in realtime, and/or toggle switch depending on a .txt file -


I'm currently creating a web interface for home automation. I am able to turn the lights on and off, but two With the different buttons I want to create a button that either closes or stops and gets it from the file on the server. The file is something like this:

  1001 = 0 1002 = 1 1003 = 0   

Note: the left digit is the light id and the correct number is the state

when the button is clicked on A shell command is executed and the status of the clicked ID varies between .txt file (which I have to work on). Now I have to see that without reloading the changes without any changes to the page opening from all the devices

I was able to get content from the file and display text, but I have no success in setting the variable: 1001, 1002, 1003, ... '0' or '1 '. Is a Simple .txt file the right choice?

Or is there a way to test the status for each specific ID if it is true or false, without the variable set?

Can you help me? Thank you.

You can not call directly a shell script via AJAX / Javascript. In case of appes (I am recommending to install wamp / xamp / lamp ), some code like user like the app and a server side Scripting language such as PDP You can call your shell script by using php code using shell_exec () or you can use the php file writing function directly to read and write the file. This PHP file can easily be said through AJAX with the appropriate parameters

I have made a similar project for my college where I send a command to a web server via the internet arduino And using a GPRS module turned on and off.

If you are interesting, executing the shell command from JS requires a very specific platform. In Windows Scripting, you do the following:

  var shell = WScript.CreateObject ("WScript.Shell"); Shell.Run ("command here");    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -