[英]How to pass multiple parameter from view to controller without ajax request
I want to pass multiple parameters from view to controller using jquery without an ajax call and I don't want to use ajax, Because that return is in jquery but I want to return view. 我想使用aquery从jquery传递多个参数到视图,而没有ajax调用,而且我不想使用ajax,因为该返回在jquery中,但是我想返回view。
<script>
$(document).ready(function () {
$(".addCF").click(function () {
var Resource = $("#ResourceId option:selected").text();
alert(Resource);
var Description = $("#ResourceDescription ").val();
alert(Description);
var Count = $("#ResourceCount option:selected").text();
alert(Count);
var Cost = $("#ResourceCostId option:selected").text();
alert(Cost);
var Duration = $("#ResourceDuration option:selected").text();
alert(Duration);
$.ajax({
url: '@Url.Action("ResourceList", "Home")',
data: { Resource: Resource, Description: Description, Count: Count, Cost: Cost, Duration: Duration },
datetype: 'json',
contenttype: "application/json",
type: "GET",
success: function (data) {
location.reload();
}
});
});
});
</script>
Any suggestion please? 有什么建议吗?
You will need a form to submit. 您将需要提交表格。 Then use
.submit()
https://api.jquery.com/submit/ If you are using razor your can create a from like this. 然后使用
.submit()
https://api.jquery.com/submit/如果您使用的是razor,则可以这样创建一个。
@Html.BeginForm("YourAction", "YourController", FormMethod.Post)
Then have your controller return a view. 然后让您的控制器返回一个视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.