I currently have the following code snippets:
Home Controller:
public IActionResult Index()
{
return View();
}
public ActionResult Transfer()
{
string path = @Url.Content(webRootPath + "\\SampleData\\TruckDtrSource.json");
if (System.IO.File.Exists(path))
{
System.IO.File.Delete(path);
}
return View();
}
public ActionResult FindTruck()
{
return View("Transfer");
}
In Transfer.cshtml:
<button id="btnTransfer" name="btnTransfer" class="btn btn-success center-block" onclick="FindTruck();">Search</button>
<script>
function FindTruck() {
$.ajax({
type: "GET",
url: "/Home/FindTruck",
async: true,
success: function (msg) {
ServiceSucceeded(msg);
},
error: function () {
return "error";
}
});
}
</script>
Whenever the user triggers the click event on "btnTransfer", I want to extract the data from the textboxes and send it to my Controller.