The scope of a variable is only within a function if declared as
function whatever() {
var a = 'hello'
}
Once that function passes, a is not available elsewhere. IF you want a to be global, declare 'var a' outside of a function (normally at the very top if your script) or don't use 'var' at all, it will be created as a global.
if (a == undefined) will always throw an error if a is undefined. To check for a 'undefined' var, use:
if (typeof a == 'undefined') -----
DroidScript is javascript. Again, I recommend you do some beginners tutorials on that first. :)
As your devices are connected by WiFi, you should turn off the ADB option in DroidScript.
Then when you start the server, it will display an ip address to type into your PC browser.
You need to change
var a = data.provider + ":Lat" + data.latitude + ",Lng" + data.longitude;
to
When I run code in my head, I skip comments without looking at them.
If you turn off the "use ADB" option in the DroidScript settings box, then restart the WiFi server in DroidScript, a box will pop up with an address provided by your router.
This will probably be 192.161...
It will definitely not be 127.0.0.1
Each Android device will expose a different ip address so you can use different browser tabs on your PC for different phones/tablets.
Neither of those is right, you need.
if (typeof a == "undefined")
Also, there is no point in running loc_OnChange from a setTimeout
That function will be called by the locator when it has some data for you.