How can I send int array from $.ajax to c# mvc?
You can simply pass a JavaScript Array variable in the $. ajax as any other variable. On PHP script you can directly use it as a normal PHP Array.
ajax() method allows you to send asynchronous http requests to submit or retrieve data from the server without reloading the whole page.
DataTables has the ability to read data from virtually any JSON data source that can be obtained by Ajax. This can be done, in its most simple form, by setting the ajax option to the address of the JSON data source.
$.ajax({ url: <Url of the action>, type: "POST", data: JSON.stringify([1,2,3]), dataType: "json", contentType: 'application/json; charset=utf-8' });
and in the action.
public ActionResult ReceiveIntArray(int[] ints) { ... }
mvc should parse the json automatically.
check out this question.
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