I have a page that does a JSON result, get and post method in the controller with two submit buttons. One button goes to the Post method only for a redirect, and the other button goes to the JsonResult method(named AddTableData). How do I set this up in my JQuery code?
$('#firstSubmit').click(function() {
$(document).submit(function() {
});
});
$('#secondSubmit').click(function() {
$('#addTable').submit(function() {
$.post($(this).attr("action"), $(this).serialize(), function(response) {
...load Table
});
return false;
});
});
<%using (Html.BeginForm("LoadTable", "Home", FormMethod.Post, new { id = "addTable" })) %>
<td><input id="Submit1" type="submit" name="firstSearch" value="Search" /></td>
<td><input id="Submit2" type="submit" name="secondSearch" value="Search" /></td>
How do I use the firstSubmit to hit the post only, and the second submit to work the JsonResult only?
EDIT
$('#secondSubmit').click(function() {
$.getJSON("Home/AddTableData", {Name:"Name on Document"}, function(json) {
alert("good");
});
});
My variables that usually get picked up on a get/post function is gone. How do I post them to my JSon function?