I encountered an issue where the ajax post method was unable to pass a parameter to the controller, as the controller parameter always appeared as Null.
Index.schtml: I attempted to initiate a new view via a parameter by triggering an element in HTML and passing the controller and action using Url.Action
within the element. Following that, I executed the script:
function getPList(target)
{
var Pdata = JSON.stringify({
'sNo': "88888888"
});
$ajax({
type: "POST",
dataType: 'json',
contentType: 'application/json',
url: target,
data: Pdata,
success: function (data) {
console.log("Response Data ↓");
console.log(data);
}
});
}
Controller:
public ActionResult PListIndex(String sNo)
{
return View(sNo);
}
How can I successfully pass the controller parameter?