I have the following:
var inf = { PID: pid, PDate: pdate};
I then have a call to the function
SetVal(inf);
function SetVal(inf) {
alert(inf.PID);
— the above works fine. I show the alert fine
But if I have it has a hyperlink which makes a call to SetVal it does not work:
valset = '<li><a href=\'javascript:SetVal(' + inf + ');\' ><h3> ' + this.PID + '</h3><p>'
$('#DataSet).html(valset);
When I click on the hyperlink I get the following message in FireBug:
missing ] after element list
Not sure how to resolve it. I thought they would be one in the same.
Your variable “inf” is an object, but you’re trying to treat it as a string when you build that element. You’d be much better off just doing it with jQuery: