I have the following @Html.DisplayFor
, how could I take the ID and pass it to an AJAX object?
@Html.DisplayFor(modelItem => item.Regla, new { id = "reglaid" })
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input id="botonformularios" type="submit" value="Create" class="btn btn-default" />
</div>
</div>
I tried the following lines, but when I pass it to the controller, I am listed as null
:
$("#botonformularios").click(function () {
var obj = {
Rid:$("#reglaid").children("input").val(),
Result: $("#result").parents().children("input").val(),
}
$.ajax({
type: 'POST',
contentType: false,
url: "/ZsvalWorkflow/Create",
dataType: 'json',
contentType: "application/json; charset=utf-8",
data: JSON.stringify(obj),
success: function (data) {
alert(data)
},
});
})