Spinneret refresh webpage
Podion
Posts: 90
Hello all,
I wonder why I always need to refresh the webpage to open the user LED on Spinerret ? I use the demo code on http://spinneret.servebeer.com:5000/client/sget.htm
When I click on LED ON the URL changes but the LED does not light. I have to refresh the page and then the LED turn on.
I wonder why I always need to refresh the webpage to open the user LED on Spinerret ? I use the demo code on http://spinneret.servebeer.com:5000/client/sget.htm
When I click on LED ON the URL changes but the LED does not light. I have to refresh the page and then the LED turn on.
Comments
The referenced page shows how to invoke a client get and has nothing to do with LEDs.
Please post your source code.
There is all the files I use in my program.
I use Safari or Google Chrome.
The globalCache is set to 0... can you tell me what dose it make?
And can you tell me why I see all the Header code on the webpage?
This Demo work fine! But now if I want to access this Demo outside of my Home Network on internet what is the next step I have to do?
Thank you very much for your help!
You must configure your router - assuming you have a router.
See the port forwarding guide which can be found on the Spinneret tutorial
http://forums.parallax.com/attachment.php?attachmentid=82190&d=1308163657
The second time I click on LED ON the page load from cache.. whatever globalCache is 1 or 0 do you know why ?
check the PIR LED
But how can I turn off the cache directly on the spinneret to provide those problem whit all user...?
Maybe i forgot something because all the Header appear on the top of the web browser... and if i delete the Heather it dose nothing.
In the 14.9 Cache-Control i see "no-cache" it could be a solution ? were can i put the "no-cache" to make it work?
As far as getting around the cache, there may be a solution using an iframe tag where the Spinneret is referenced from another page as the iframe contents ... This also has an advantage of not affecting the browser history.
I'll have to think about it to implement something with the Spinneret, but I have done something similar in the past allowing for bi-directional dynamic data flow between two pages.
Yes this could be cool !
ServerCode.html
ClientCode.html
Thank you !
I'm probably missing the point. As far as I can tell there are two pages executing JavaScript on the client. Data is passed on the DOM.
At some point you'll probably want to make an HTTP request which is invoked by the browser. The same caching rules will apply.
I would use AJAX over an iframe. To get around the cache, insert the current time to the URL querystring.
...an HTTP request happens within an iframe and does not effect the browser history or add or append data to the the parent browser URL tag. You can make the HTTP request dynamic by placing the iframe within a div and change the content with an innerHTML command in javascript.
First time poster and new spinneret/propeller user...I have tried to modify your code that is posted on http://spinneret.servebeer.com:5000/gstart/get.htm , and I do not get my local web page any more.
I ran through all Mike Gs instructions by the numbers, had it working until I added a servo and what I thought was the html adding a button for the servo (on/off)...
my code looks like :
PRI Dispatcher2(id)
''do some processing before sending the response
if(strcomp(Request.GetName(id), string("servo")))
Demo (id)
StaticFileHandler(id)
return
PRI Demo(id) | qstr
'' Get the query string value
qstr := Request.Get(id, string("servo"))
if (strcomp( string("on"), qstr ))
ServoStatus(1)
else
ServoStatus(0)
return
PRI ServoStatus(state)
cognew(MoveMotor(26),@StackSpace4) 'Start a new cog and run the MoveMotor method on it that outputs pulses on Pin 7
'The new cog that is started above continuously reads the "position" variable as it's changed by the example Spin code below
repeat
position:=100 'Start sending 1ms servo signal high pulses (100 * 10us = 1ms)
waitcnt(clkfreq+cnt) 'Wait for 1 second (1ms high pulses continue to be generated by the other cog)
position:=138 'Start sending 1.38ms servo signal high pulses (Center position)
waitcnt(clkfreq+cnt) 'Wait for 1 second (1.38ms high pulses continue to be generated by the other cog)
position:=50 'Start sending 0.5ms servo signal high pulses (Clockwise position)
waitcnt(clkfreq+cnt) 'Wait for 1 second (0.5ms high pulses continue to be generated by the other cog)
position:=225 'Start sending 2.25ms servo signal high pulses (Counterclockwise position)
waitcnt(clkfreq+cnt)
return
PUB MoveMotor(Pin) 'This method outputs a continuous stream of servo signal pulses on "Pin"
dira[Pin]~~ 'Set the direction of "Pin" to be an output
repeat 'Send out a continous train of pulses
outa[Pin]~~ 'Set "Pin" High
waitcnt((clkfreq/100_000)*position+cnt) 'Wait for the specifed position (units = 10 microseconds)
outa[Pin]~ 'Set "Pin" Low
waitcnt(clkfreq/100+cnt) 'Wait 10ms between pulses
...the rest of the code is using exactly what Mike had; I did add the requisite StackSpace for the new cogs, the variables, etc....the code loaded on to the Spinneret, I kept the index.htm page as is, then I modified the led.htm web page to look like:
<html>
<head>
<title>GETing to the Server</title>
</head>
<body>
<div style="width:600px;margin:auto;">
<h1 style="text-align:center;color:blue;">LED</h1>
<div style="text-align:center;"><a href="index.htm">Hello World</a> | <a href="led.htm">LED</a></div>
<p><a href="led.htm?led=on">LED On</a> :: <a href="led.htm?led=off">LED Off</a></p>
<p>LED: <span id="placeholder"></span></p>
<p><a href="led.htm?servo=on">SERVO On</a> :: <a href="led.htm?SERVO=off">SERVO Off</a></p>
<p>LED: <span id="placeholder"></span></p>
</div>
</div>
</body>
</html>
All the networking pieces worked fine, got the web page, turned on the led via the web server, then I did the above mods and all is no go. I get this message:
The connection was reset
The connection to the server was reset while the page was loading.
Please help!