# Json problem to add button at map , the popup button not works as json send data

**URL:** <https://discourse.nodered.org/t/json-problem-to-add-button-at-map-the-popup-button-not-works-as-json-send-data/35132>\
**Category:** Dashboard\
**Created:** [31 October 2020 22:11 UTC](https://discourse.nodered.org/t/json-problem-to-add-button-at-map-the-popup-button-not-works-as-json-send-data/35132 "2020-10-31T22:11:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![halukmy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/halukmy/32/31192_2.png) [@halukmy](https://discourse.nodered.org/u/halukmy)\
**Post date:** [31 October 2020 22:11 UTC](https://discourse.nodered.org/t/json-problem-to-add-button-at-map-the-popup-button-not-works-as-json-send-data/35132/1 "2020-10-31T22:11:43Z")

</div>

```auto
  "{"name":"1310","Uygulanan Enerji":"6","Bağlı Uygulama":"DownPole","Cihaz Özellikleri":"XEN Module","layer":"areylight","weblink ":"areylight,","lat":37.027859, "lon":27.987977,"popup":'<button type = "button" onclick ='feedback("Dave","some data you want to send")'>Click Me!</button> ',"icon":"https://image.flaticon.com/icons/png/512/2892/2892056.png"}"

```

[@dceejay](https://github.com/dceejay) whats wrong on this string? i get this error  
"Unexpected token ' in JSON at position 184"

just try to simulate

msg.payload = {  
name:"Dave",  
lat:51.05,  
lon:-1.35,  
popup:'Click Me!'  
}  
return msg;

but somethng wrong

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [31 October 2020 22:53 UTC](https://discourse.nodered.org/t/json-problem-to-add-button-at-map-the-popup-button-not-works-as-json-send-data/35132/2 "2020-10-31T22:53:57Z")

</div>

you need to escape the ' inside the html correctly so `\'feedback ... send")\'`

---

<div class="post-metadata">

**Author:** ![halukmy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/halukmy/32/31192_2.png) [@halukmy](https://discourse.nodered.org/u/halukmy)\
**Post date:** [1 November 2020 22:07 UTC](https://discourse.nodered.org/t/json-problem-to-add-button-at-map-the-popup-button-not-works-as-json-send-data/35132/4 "2020-11-01T22:07:36Z")

</div>

i have find an interesting bug!

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/f/5f9a6734c5a54c1f1df7cfc5b31b257546fdc554.png)

if i only send button event whitout your sample ( most important is "name" tag must be same )

event doesnt work.. but if i same time trigger it works!

name: "areylight"

lat: 37.02

lon: 27.98

popup: "Click Me!"

this is ur sample

name: "areylight"

lat: 37.02

lon: 27.98

popup: "Click Me!"

and this is mine

name: "DownPole"

Uygulanan Enerji: "123"

Bağlı Uygulama: "4444"

Cihaz Özellikleri: "555"

layer: "areylight"

weblink : "areylight,"

lat: 37.028724

lon: 27.984386

icon: "[https://www.flaticon.com/svg/static/icons/svg/2892/2892056.svg](https://www.flaticon.com/svg/static/icons/svg/2892/2892056.svg)"

popup: "Click Me!"

the sending code is

{"name":"NorthSide","Uygulanan Enerji":"123","Bağlı Uygulama":"4444","Cihaz Özellikleri":"555","layer":"areylight","weblink ":"areylight,","lat":37.029812, "lon":27.986004,"icon":"[https://www.flaticon.com/svg/static/icons/svg/2892/2892056.svg","popup":"](https://www.flaticon.com/svg/static/icons/svg/2892/2892056.svg%22,%22popup%22:%22)\<button type="button" onclick='feedback("areylight","areylight#NorthSide")'\>Click Me!"}

problem is, if im not publish your code somewhere it doesnt apply event.. i can record video if you dont understand

everything same but

name tags must be same, if not, the button trigger doesnt work

---

<div class="post-metadata">

**Author:** ![halukmy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/halukmy/32/31192_2.png) [@halukmy](https://discourse.nodered.org/u/halukmy)\
**Post date:** [1 November 2020 22:08 UTC](https://discourse.nodered.org/t/json-problem-to-add-button-at-map-the-popup-button-not-works-as-json-send-data/35132/6 "2020-11-01T22:08:22Z")

</div>

```auto
[{"id":"4d69f162.a0cf6","type":"mqtt in","z":"6b09647d.880fbc","name":"","topic":"test1","qos":"2","datatype":"json","broker":"10c6683d.a5b258","x":210,"y":1380,"wires":[["5b05d00b.8bb92","7ae374de.4010fc"]]},{"id":"c422aa7d.2e40c8","type":"change","z":"6b09647d.880fbc","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"command\":{\"clear\":\"areylight\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1420,"y":1260,"wires":[["a997a4f3.2c0948"]]},{"id":"65c4d792.1111c8","type":"mqtt in","z":"6b09647d.880fbc","name":"","topic":"test1clear","qos":"2","datatype":"auto","broker":"695d4038.71a07","x":1740,"y":1260,"wires":[["c422aa7d.2e40c8"]]},{"id":"2234135b.b7521c","type":"debug","z":"6b09647d.880fbc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":960,"wires":[]},{"id":"5b05d00b.8bb92","type":"function","z":"6b09647d.880fbc","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":480,"y":1180,"wires":[["2234135b.b7521c","a997a4f3.2c0948"]]},{"id":"1c44ccd.1cb9733","type":"mqtt out","z":"6b09647d.880fbc","name":"","topic":"GOKOVAOREN_MAREYNA/testvvv","qos":"","retain":"","broker":"b834fbd4.8cc698","x":590,"y":1780,"wires":[]},{"id":"bda9a026.41a2f","type":"inject","z":"6b09647d.880fbc","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":380,"y":1560,"wires":[["7ae374de.4010fc"]]},{"id":"a997a4f3.2c0948","type":"worldmap","z":"6b09647d.880fbc","name":"","lat":"37.030206","lon":"27.985364","zoom":"16","layer":"OSM","cluster":"","maxage":"","usermenu":"show","layers":"show","panit":"false","panlock":"false","zoomlock":"false","hiderightclick":"false","coords":"none","showgrid":"false","path":"/worldmap","x":1420,"y":1560,"wires":[]},{"id":"7ae374de.4010fc","type":"function","z":"6b09647d.880fbc","name":"","func":"msg.payload = {\n name:\"areylight\",\n lat:37.02,\n lon:27.98,\n popup:'<button type=\"button\" onclick=\\'feedback(\"areylight\",\"some data you want to send\")\\'>Click Me!</button>'\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":660,"y":1520,"wires":[["a997a4f3.2c0948","ffdac31a.7fc74"]]},{"id":"8065fb7.ddc6108","type":"worldmap in","z":"6b09647d.880fbc","name":"","path":"/worldmap","events":"all","x":340,"y":1720,"wires":[["ffdac31a.7fc74","1c44ccd.1cb9733"]]},{"id":"ffdac31a.7fc74","type":"debug","z":"6b09647d.880fbc","name":"","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":820,"y":1700,"wires":[]},{"id":"dda3c7c1.832fe8","type":"inject","z":"6b09647d.880fbc","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":360,"y":1920,"wires":[["1b339eb5.42bab1"]]},{"id":"1b339eb5.42bab1","type":"function","z":"6b09647d.880fbc","name":"","func":"msg.payload = {\n name:\"Dave\",\n lat:51.05,\n lon:-1.35,\n popup:'<button type=\"button\" onclick=\\'feedback(\"Dave\",\"some data you want to send\")\\'>Click Me!</button>'\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":540,"y":1920,"wires":[["a997a4f3.2c0948"]]},{"id":"10c6683d.a5b258","type":"mqtt-broker","z":"","name":"","broker":"areylight.dynu.net","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"695d4038.71a07","type":"mqtt-broker","z":"","name":"","broker":"areylight.dynu.net","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"b834fbd4.8cc698","type":"mqtt-broker","z":"","name":"","broker":"areylight.dynu.net","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

```

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [1 November 2020 23:25 UTC](https://discourse.nodered.org/t/json-problem-to-add-button-at-map-the-popup-button-not-works-as-json-send-data/35132/7 "2020-11-01T23:25:55Z")

</div>

The name is unique per point - so yes if you change the name it will apply to a different point.

---

<div class="post-metadata">

**Author:** ![halukmy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/halukmy/32/31192_2.png) [@halukmy](https://discourse.nodered.org/u/halukmy)\
**Post date:** [2 November 2020 17:56 UTC](https://discourse.nodered.org/t/json-problem-to-add-button-at-map-the-popup-button-not-works-as-json-send-data/35132/8 "2020-11-02T17:56:35Z")

</div>

no i mean, feedback name

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/5/2564357eecf25f2c91acb776312c9563df4793d3.png)

if i use different feedback "....." with code, it doesnt trigger...

---

<div class="post-metadata">

**Author:** ![halukmy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/halukmy/32/31192_2.png) [@halukmy](https://discourse.nodered.org/u/halukmy)\
**Post date:** [2 November 2020 17:57 UTC](https://discourse.nodered.org/t/json-problem-to-add-button-at-map-the-popup-button-not-works-as-json-send-data/35132/9 "2020-11-02T17:57:16Z")

</div>

```auto
{"name":"NorthSide","Uygulanan Enerji":"123","Bağlı Uygulama":"4444","Cihaz Özellikleri":"555","layer":"areylight","weblink ":"areylight,","lat":37.029812, "lon":27.986004,"icon":"[https://www.flaticon.com/svg/static/icons/svg/2892/2892056.svg","popup":"](https://www.flaticon.com/svg/static/icons/svg/2892/2892056.svg%22,%22popup%22:%22)<button type="button" onclick='feedback("areylight","areylight#NorthSide")'>Click Me!"}

```

is this ok?

---

<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 December 2020 17:57 UTC](https://discourse.nodered.org/t/json-problem-to-add-button-at-map-the-popup-button-not-works-as-json-send-data/35132/10 "2020-12-02T17:57:18Z")

</div>

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