I'm currently facing a challenge in sending multiple variables as parameters to a function called redi on an onClick event. Right now, I am only able to send one variable (id) and struggling to find a way to pass multiple variables (specifically id, nome, cognome). I attempted using onclick='redi(this.id, nome, cognome)', but it appears there is an issue with the quotes since nome and cognome are strings.
$.ajax({
url: "<URL to backend script>",
dataType: 'jsonp',
jsonp: 'jsoncallback',
timeout: 5000,
success: function(data, status){
$.each(data, function(i,item)
{
var id = item.registrationID;
var nome = item.registrationName;
var cognome = item.registrationSurname;
var id_referenza = item.registrationUsername;
document.getElementById('divPaziente').innerHTML += "<a href='"+nome+"'><button class='button button-block button-positive' id='"+id+"' onclick='redi(this.id)'>"+nome+' '+cognome+' - '+id_referenza+"</button></a>";
window.redi = function(elem)
{
alert("elem: "+elem);
localStorage.setItem("id", elem);
}
});
},
error: function()
{
output.text('There was an error while loading data.');
}
});