Use jquery data
instead:
$("#submitForm").data('transaction', transactionID);
And
var number_id = $("#submitForm").data('transaction');
Notice that this will not add the attribute to the DOM, if you inspect the element via the developers tool, you won’t see data-transaction
, but the element will have the data referenced.
Edit:
Your method should also work, but as @Tushar pointed out, you are missing the #
from your selector: $("submitForm")
-> $("#submitForm")
1
solved How can I set data-* attributes on the button when the AJAX requests complete?