Posting data from imp to http help

im trying to get data start from my imp to post on the the imps http and i cant figure it out i have spent about 3 hours trying to figure it out. im trying to get data from my two temps to post of my webpage
https://agent.electricimp.com/zeO88kkBPkGK
i know there is some useless code in her and sorry if a little hard to fallow this is the first program i have written in about 8 years

If you are getting the HTTP No Handler error, then you are missing the http.onrequest() function. Here’s an example from the Imp API reference.

https://electricimp.com/docs/api/http/onrequest/

We can’t see your code from the URL you provided… that is the Agent URL. You will need to post your code to the forum or github for us to see it.

the code there now

@bradydennis - I strongly recommend you remove your secret API keys from your agent code… those aren’t things you typically want to share.

Also - could you please explain in a bit more detail what your issue is - this is a lot of code to sift through without a good idea of what it is / is not doing :slight_smile:

I think I understand what you want. You are trying to update values on a remote HTML page with the code running on the agent. Once the browser has opened the agent URL and received the response, the transaction is complete - you can’t push new information to the browser. What you need is for the browser to request updates for the temperature values at intervals that make sense to your application.

To correct the program, I created two variables to hold sap and air temperature values and added a query function into your http handler on the squirrel side of things. In the javascript, I added a polling function that gets called through a javascript timeout function. This polling function requests the current sap and air temperature values from the agent at 1.5 second intervals and displays them on the web page. To display the values, I added span elements and gave them ids that are accessed through the document object in the browser. The temperatures are passed back in a json object, so on the javascript side we parse the string and update the inner html of the spans to display the temperatures.

Works on my side. Hope that helps. I’ve attached a screen shot of it working.

Updated code is in the attached file.

thanks that is what i need here is my working code
https://agent.electricimp.com/sQ9sYMmcP2Xf
http://forums.electricimp.com/plugins/FileUpload/images/file.png
http://forums.electricimp.com/plugins/FileUpload/images/file.png