# Read data via ajax -node red

**URL:** https://discourse.nodered.org/t/read-data-via-ajax-node-red/39327
**Category:** General
**Created:** [18 January 2021 13:07 UTC](https://discourse.nodered.org/t/read-data-via-ajax-node-red/39327 "2021-01-18T13:07:04Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![hassengh](https://avatars.discourse-cdn.com/v4/letter/h/bc8723/32.png) [@hassengh](https://discourse.nodered.org/u/hassengh)
#### Post date: [18 January 2021 13:07 UTC](https://discourse.nodered.org/t/read-data-via-ajax-node-red/39327/1 "2021-01-18T13:07:04Z")

</div>

Dear all ,  
I have application php/html , I want to read (via AJAX ) value of sensor via node red ?  
Someone has idea how to read value sensor via AJAX ?  
thanks

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [18 January 2021 19:18 UTC](https://discourse.nodered.org/t/read-data-via-ajax-node-red/39327/2 "2021-01-18T19:18:17Z")

</div>

You posted in the incorrect area of the forum.

If I understand it correctly, you want to read a sensor value from your php application. You can accomplish this by setting up an http endpoint. In the documentation you will find the “cookbook” with examples. It comes down to: setup a certain url, get the sensor value, set that as a response.

---

<div class="post-metadata">

### Author: ![hassengh](https://avatars.discourse-cdn.com/v4/letter/h/bc8723/32.png) [@hassengh](https://discourse.nodered.org/u/hassengh)
#### Post date: [19 January 2021 09:12 UTC](https://discourse.nodered.org/t/read-data-via-ajax-node-red/39327/3 "2021-01-19T09:12:53Z")

</div>

I want send data to my private dashbord without node red  
I want read data sensor via node red and send it to my private dashbord(in php /html)

```auto
[{"id":"2c536f36.9fef7","type":"tab","label":"Flow 12","disabled":false,"info":""},{"id":"fae77e41.e4291","type":"inject","z":"2c536f36.9fef7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"power\":500,\"cosphi\":0.98,\"status\":\"ok\"}","payloadType":"json","x":140,"y":100,"wires":[["97e88997.b95288"]]},{"id":"97e88997.b95288","type":"http request","z":"2c536f36.9fef7","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"localhost:1880/test/energie","tls":"","persist":false,"proxy":"","authType":"","x":360,"y":120,"wires":[["1db0a089.213b5f"]]},{"id":"1db0a089.213b5f","type":"debug","z":"2c536f36.9fef7","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":560,"y":160,"wires":[]}]

```

---

<div class="post-metadata">

### Author: ![hassengh](https://avatars.discourse-cdn.com/v4/letter/h/bc8723/32.png) [@hassengh](https://discourse.nodered.org/u/hassengh)
#### Post date: [19 January 2021 09:13 UTC](https://discourse.nodered.org/t/read-data-via-ajax-node-red/39327/4 "2021-01-19T09:13:31Z")

</div>

[Node-Red HTTP Request Node Posting Data to Thingsboard - YouTube](https://www.youtube.com/watch?v=wW_UeqeszEs)

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [19 January 2021 09:38 UTC](https://discourse.nodered.org/t/read-data-via-ajax-node-red/39327/5 "2021-01-19T09:38:42Z")

</div>

As said, you can do this with a http end-point;

 ![Screenshot 2021-01-19 at 10.32.44](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/0/608cd14153f1e908e163d304508ed823b7ab87c4.jpeg)

- update the sensor data as a flow variable
- set up an end-point which retrieves the flow variable and expose it to an url.

example flow

```auto
[{"id":"e8ab1382.d91dc","type":"http in","z":"2c536f36.9fef7","name":"","url":"/test","method":"get","upload":false,"swaggerDoc":"","x":202,"y":288,"wires":[["c00327db.80111"]]},{"id":"c77d0d3a.702e6","type":"http response","z":"2c536f36.9fef7","name":"","statusCode":"","headers":{"content-type":"application/json"},"x":530,"y":288,"wires":[]},{"id":"1b528541.50d223","type":"inject","z":"2c536f36.9fef7","name":"Sensor data input","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"power\":500,\"cosphi\":0.98,\"status\":\"ok\"}","payloadType":"json","x":234,"y":216,"wires":[["3a483e00.946312"]]},{"id":"3a483e00.946312","type":"change","z":"2c536f36.9fef7","name":"","rules":[{"t":"set","p":"sensor","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":442,"y":216,"wires":[[]]},{"id":"c00327db.80111","type":"change","z":"2c536f36.9fef7","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"sensor","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":368,"y":288,"wires":[["c77d0d3a.702e6"]]}]

```

- Press the inject node.
- Open a browser tab and go to `http://<yournode-red-ip:1880>/test/`

You will get the json output, this url you can use in your custom html application

---

<div class="post-metadata">

### Author: ![hassengh](https://avatars.discourse-cdn.com/v4/letter/h/bc8723/32.png) [@hassengh](https://discourse.nodered.org/u/hassengh)
#### Post date: [19 January 2021 10:26 UTC](https://discourse.nodered.org/t/read-data-via-ajax-node-red/39327/6 "2021-01-19T10:26:57Z")

</div>

thanks for your reply 😉  
it is working fine 🙂

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [2 February 2021 10:27 UTC](https://discourse.nodered.org/t/read-data-via-ajax-node-red/39327/7 "2021-02-02T10:27:03Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
