2021年4月28日星期三

jQuery AJAX Post String to MVC Controller Null Parameter

I have a pretty simple AJAX call I am trying to make, which is a search string that will POST a value to a controller as a search string.

$.ajax({              url: '/ResultsProcessing/AthleteLookup/n',              type: 'POST',              data: searchstring,              processData: false,              contentType: "application/x-www-form-urlencoded",              dataType: 'html',              success: function (response) {                  console.log(response);                  if (response) {  // check if data is defined                       //Do something                  }              }          });  

However, whatever I try and configure, my controller never receives the string parameter

        [HttpPost]          public async Task<IActionResult> AthleteLookup(string searchstring)  

It is probably something really dumb. But how do I get that search parameter passed to my controller

https://stackoverflow.com/questions/67301907/jquery-ajax-post-string-to-mvc-controller-null-parameter April 28, 2021 at 10:10PM

没有评论:

发表评论