I'm trying to create and submit a form through code. What's wrong with the below?
$('#btnPrintInvoicePerFile').on('click', function (event) {
event.preventDefault(); //stop link default
var componentInvoiceId = EberlsComponentInvoiceForm.componentInvoice.Id;
console.log(componentInvoiceId);
$('<form>', {
"id": "getInvoiceImage",
"html": '<input type="text" id="componentInvoicId" name="componentInvoicId" value="' + componentInvoiceId + '" />',
"action": window.siteRoot + 'ComponentInvoice/GetInvoiceImage/'
}).submit();
});
Try to append the form to the body element first:
$('<form>', {
"id": "getInvoiceImage",
"html": '<input type="text" id="componentInvoicId" name="componentInvoicId" value="' + componentInvoiceId + '" />',
"action": window.siteRoot + 'ComponentInvoice/GetInvoiceImage/'
}).appendTo(document.body).submit();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With