Agent serving page - inhibit reload resending

Using the recent Blog on having an agent serve a webpage, I set up my agent to do the same and expect a password to be entered in order to validate the request. Everything works fine…except that a page reload re-sends the request and I’d like to prevent that behavior. I’ve tried sending meta data to have the cache expire, but without any success using Safari and Firefox.

Any advice would be appreciated.

`
function setPage() {
local page = @“



xxx - Chiller Reset





<img src=‘http://xxx.jpg’ alt='xxx’

xxx - Chiller Reset



Number of seconds to shut off for reset:


4
8


Password







”+message+@"


"
return page

}

http.onrequest(function(request, response)
{
try
{
local method = request.method.toupper()

if (method == "POST") 
{
  local data = http.urldecode(request.body)
  server.log("seconds: "+data.resetSeconds)
  server.log("password: "+data.password);
  if (data.password==stePassword){
      server.log("valid password entered");
      device.send("resetController",data.resetSeconds);
      message = "Chiller reset request sent"
  }
  else {
      server.log("bad password: "+data.password);
      message = "Invalid password entered."
  }
  response.send(200,setPage());
  message = "";
}
else
{
  message = "";    
  response.send(200, setPage());
}

}
catch(error)
{
message = error;
response.send(500, setPage())
}
})
`

I think your issue is very much an html / web browser compatibility problem… some suggest using autocomplete=‘off’ within <form method='POST' autocomplete='off'>

Anyhow, why don’t you use javascript / jquery / ajax to handle data transfer rather than html form post method. The benefit is that you can then handle form validation and it does not create a screen refresh. You can add in java functionality that detects form loading (onload() method? ) to ensure all password data is cleared etc.

I used this onclick() method to handle posting of data… which is slightly different to submit button method… note there is stuff on the net which gives examples using submit method.

So instead of <input type='submit' value='Submit'>,

I used <button onclick='myFormSubmitFunction()'>Submit</button>

Then in your case you would need to create an “id” reference, well that is how I handled it for:

<select name='resetSeconds' id='resetSeconds'><option value=4>4</option> <option value=8>8</option></select>

and same for password <input type='password' name='password' id='password'>

These “id’s” can then be references in a java “script” which you place inside the “body” section, typically at the bottom within “script” tags.

I created a function script, something like this:

`

`

Thanks for the tip. I’ll have to look at modifying my page to include this technique!