Reputation: 77
when I try to pass this value, I get this error
09 is not a legal ECMA-262 octal constant [Break On This Error]
linkClicked(SS-10-04-2012-0199)
javasc...2-0199) (line 1, col 26) SS is not defined
Not sure what it means, tried converting the value to string beforehand etc but then it won't read at all
for(var i=0; i < resultArray.length; i++){
var temp = resultArray[i].pp_order_details_id;
$('#results').append('<tr><td><a href="javascript:linkClicked(' + temp + ')">' + resultArray[i].pp_order_details_id + '</a></td><td>' + resultArray[i].order_ref + '</td><td>' + resultArray[i].status + '</td></tr>');
}
Above is where the data is written to the table The user should click the link, and the pp_order_details_id should be passed to the linkClicked function below
function linkClicked(orderno) {
$.post("../../order/get-order.php", {
orderRef: orderno
}, function (data) {
if (data.match("set")) { $('#my_order_details').fadeOut("fast").load('index#my_order_details').fadeIn("fast");
}
});
}
I'm probably doing the passing thing wrong because I'm not used to it, but thought I'd ask
Upvotes: 0
Views: 987
Reputation: 166031
By the look of the error message this is your call to linkClicked
:
linkClicked(SS-10-04-2012-0199)
But you need to pass a string. Notice the addition of the escaped '
characters:
$('#results').append('<tr><td><a href="javascript:linkClicked(\'' + temp + '\')">' //...
This should result in the call looking like this:
linkClicked('SS-10-04-2012-0199')
Upvotes: 1