我想传递参数数组和字符串但不发送字符串参数来控制操作。我使用这段代码:
public virtual async Task<ActionResult> Create(AddCategoryModel viewModel, string id) {}
我使用此代码json但不将id
传递给action:
<script>
$(document).ready(function(){
$(".btn-success").click(function(e)
{
var formData = JSON.stringify($("#ajaxform").serializeArray());
alert(formData);
var MyForm = $("#ajaxform").serializeJSON();
console.log(MyForm);
$.ajax(
{
url : "/Category/Create/", //,+ //$(foo).val(),
//url: "Url.Action("Category", "Create", new { id = "oo" })",
//id: $(foo).attr('value') ,
type: "POST",
data : {valArray:formData,'id':'20'},
success:function(maindta)
{
alert(maindta);
},
error: function(jqXHR, textStatus, errorThrown)
{
}
});
e.preventDefault(); //STOP default action
});
});
</script>