get return of bridge in javascript variable

Hello All,

I have searched this forum but didn't find any satisfactory help. Here is my question.

following the TemperatureWebPanel sample, I can read the return of my updated sensor value using :

$('#content').load('/arduino/temperature');

However, I don't want to put it in a HTML tag but in a javascript variable, for further processing.

I tried :

var temp; temp.load('/arduino/temperature');

but this doesn't work.

Can you help, please ?

Best regards

If you want just the temperature and none of the surrounding text, then you'll need to use a different server. OR rewrite the server to only return the temperature.

It might look like this:

if (command == "temperature") {
      int sensorValue = analogRead(A1);
      // convert the reading to millivolts:
      float voltage = sensorValue *  (5000/ 1024); 
      // convert the millivolts to temperature celsius:
      float temperature = (voltage - 500)/10;
      client.print(temperature);
}

Jesse