Append a jQuery variable to a event click function

Append a jQuery variable to a event click function

I have a script that processes some Json data to produce a graph using HighCharts. The Json data has three elements:

[{"name":"Room","data":[343,405,406,407]}, {"name":"Temp C","data":[50,50,50,50]}, {"name":"UniqueID","data": ["GLAZH03431464336298","GLAZH04051465483111","GLAZH04061464783558","GLAZH04071465484869"]}]
In my script I have the following:

$(document).ready(function() { $.getJSON("temp_chart.php", function(json) { $.each(json,function(i,el) { if (el.name=="Room") categories = el.data; else if (el.name=="UniqueID") { uniqueid = el.data; } else data.push(el); });

What I want to do is pass the "uniqueid" and append it to the end of a URL in a event click like:

click: function() { window.top.location.href = "water.php?room=" + this.uniqueid; }

If I use "console.log(uniqueid, "UniqueID");" in the script and check the content in a debugger, I see:

Array [ "GLAZH03431464336298", "GLAZH04051465483111", "GLAZH04061464783558", "GLAZH04071465484869"]

My question is how can I append the content of uniqueid to the end of my URL for the click event. Whatever I do I can't get this to work.

Your help would be great and thanks for any time you may give.