how to pass the value of frm and other parameter susing ajax and jquery?
hi im stuck here for many days please help me. i need to pass the value of selected ids into ajax . but my parameter is null
but when i remove this part. the the ids has a value but my model parameter is null. i need to pass the value of both parameter
- var fileInput = $('#files');
- var filename = fileInput.files[0].name
- formdata.append(filename, fileInput.files[0]);
this is my full code.
- var table;
- $(function () {
- table = $('#Payable').DataTable({
- "ajax": "@Url.Action("getpayablelist", "payment")",
- "columns": [
- {
- "render": function (data, type, full, meta) {
- return "<input type='checkbox' class='selected' onclick='add(" + full.Id + ", " + full.Amount + ", this.checked)'>"
- }
- },
- { "data": "Type" },
- { "data": "ReferenceNo" },
- { "data": "Amount" }
- ]
- });
- });
- function edit(id) {
- window.location.href = "@Url.Action("add", "order")?id=" + id;
- }
-
- var ids = [];
- function add(id, isChecked) {
- if (isChecked) {
- ids.push(id);
- }
- else {
- var i = ids.indexOf(id);
- ids.splice(i, 1);
- }
- }
- $(document).ready(function () {
- $("#btnUpload").click(function () {
- var model = $('#addcompanydata').serialize()
- var fileInput = $('#files');
- var filename = fileInput.files[0].name
- formdata.append(filename, fileInput.files[0]);
- $.ajax({
- type: "POST",
- url: '@Url.Action("index", "payment")',
- data: { model: model, ids: ids },
- dataType: 'json',
- traditional: true,
- success: function (result) {
- console.log(result);
- },
- })
- return false;
- });
- });