Friday 15 March 2013

javascript - JSON and Python -


I am developing a web interface for Arduino, using Python. For automatic updates and performance, I use JSON. I have a very interesting problem.

The following code sends commands to a python function, if there is a command. Again, whether the command has been sent to the function or not, the function checks for updates of Arduino, by calling another function.

Here I can not find any explanation: the status of the first and only update () function, if I delete that line which tells the warning ('O'); Python function is no longer called. But if I write alerts ('he'); After the JSON request, it works fine, the function is called and arduino receives the message

Why does anyone have an idea?

  function update (command = 0) {// If a command has been passed, send it (command! = 0) {$ .getJSON ('/ action command =?' + Command); Warning ('O'); // If I delete it, then the action function is not called. Why? } // read from the read function, no matter how much $ $ .getJSON ('/ read', {}, function (data) {if (data.state! = 'Failure' & doccontent! = '' $ ('Notice'). Text (data content); $ ('notice'). Skip (). Feedin ('slow'); settimeout (function () {$ ('notice'). Feeds (1000) ;}, Set timeout (update, 5000); // next update 5 seconds});} update (); page load    

are you checking for the results first order with another? If so I suspect that the warning ('O') is adequately preventing enough execution to finish. Do you have to first getJSON

  Function update (command = 0) {if (command! = 0) {$ .getJSON} can you try to teach the callback function? ('/ Verb? Command =' + command, function () {read ();}); } Else {read (); }} Read the function () {$ .getJSON ('/ read', {}, function (data) {if (data.state! = 'Failure' & amp; amp; data.content! = '') {$ ( $ ('Notice'). $ ('Notice'). Hide Fidin ('slow'); setimimate (function () {$ ('notice'). Fadeaut (1000);}, 1500);} SetTimeout (Update, 5000); // Next Update 5 secs});} First call on Update (); Page Load   

for //

No comments:

Post a Comment