Skip to content

Instantly share code, notes, and snippets.

@rionmonster
Created April 27, 2016 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rionmonster/b80ea1ad6eafa5ae9347b0d333f84092 to your computer and use it in GitHub Desktop.
Save rionmonster/b80ea1ad6eafa5ae9347b0d333f84092 to your computer and use it in GitHub Desktop.
namespace ExampleProject.Controllers
{
public class HomeController : Controller
{
[HttpGet]
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult ExamineeResults(SampleFormData[] formData)
{
return View();
}
}
public class SampleFormData
{
public string Birthdate { get; set; }
public string ROWID { get; set; }
public string Score { get; set; }
public string SpecCodes { get; set; }
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<title>Post Testing</title>
</head>
<body>
<script>
$(function () {
var formData = "[{\"Birthdate\":\"1947-03-21\",\"ROWID\":\"000001\",\"SpecCodes\":\"987654\"}]";
$.ajax({
type: 'POST',
url: '@Url.Action("ExamineeResults","Home")',
cache: false,
data: { formData: JSON.parse(formData) },
success: function (data) {
alert("sent data to controller")
},
error: function (data) {
alert("Error " + data.responseText);
}
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment