Reputation: 128
I send two parameters, a number ($row ["inv_id"]
) and a string ($status = "Close"
) to a function jquery php
$ inv_actions= <a onClick="invoiceStatusChange('.$row["inv_id"].','.$status.')" title="Close"><i class="icofont icofont-unlocked"></i></a>';
and I receive it in jquery
function invoiceStatusChange (invId, toStatus) {
alert (toStatus);
}
present this error
invoiceStatusChange (532, Close) Uncaught ReferenceError: Close is not defined
If I send the number alone there is no problem, if I send two numbers, there is no problem, but if I send the number and the string gives the error.
Can you help? Thank you
Upvotes: 0
Views: 23
Reputation: 1039
You need to add backslashes with single quote
$inv_actions= '<a onClick="invoiceStatusChange(\''.$row["inv_id"].'\',\''.$status.'\')" title="Close"><i class="icofont icofont-unlocked"></i></a>';
OR
$inv_actions= '<a onClick="invoiceStatusChange("'.$row["inv_id"].'","'.$status.'")" title="Close"><i class="icofont icofont-unlocked"></i></a>';
Upvotes: 1