0

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

1 Answer 1

1

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')
3
  • fantastic! don't understand why the first backslash is before the first apostrophe, but it worked great!
    – Pam
    Apr 26, 2012 at 12:33
  • @Pam - It's there because the second apostrophe is the one that ends the string literal being passed to append. The first apostrophe is part of that string literal, if that makes sense. In any case, glad I could help :) Apr 26, 2012 at 12:35
  • Yeah, I stared at it a bit after and I understood what was happening :) Thanks for that!
    – Pam
    Apr 26, 2012 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.