Created
April 27, 2016 15:55
-
-
Save rionmonster/b80ea1ad6eafa5ae9347b0d333f84092 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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