Hi Everyone,
I have the following javascript code:
- <script>
- function RequestData() {
- var Nos = $("#search").val();
- var DataIntervals = $("#txtDataInterval").val();
- var StartDates = $("#start_date").val();
- var EndDates = $("#end_date").val();
- if (Nos != null && DataIntervals != null && StartDates != null && EndDates != null)
- {
- $.ajax({
- type: "POST",
- async: false,
- url: 'ExtractData/ExtractData',
- data: { 'No': Nos, 'DataInterval': DataIntervals, 'StartDate': StartDates, 'EndStart': EndDates},
- contentType: "application/json; charset=utf-8",
- dataType: "json",
- success: function (msg) {
- alert("The Query Has Completed Successfully.");
- },
- error: function (e) {
- alert("Something Went Wrong Please Try Again." + e);
- }
- });
- } else
- {
- alert("Please Select All The Required Fields and Try Again.");
- }
- }
- </script>
I'm trying to pass to parameters to C# method but they always null.
Here is my C# method:
- [HttpPost]
- public IActionResult ExtractData(string No, string DataInterval, string StartDate, string EndStart)
- {
- string x = No;
- return View();
- }
What is it I'm doing wrong that makes this method parameters to always be null?