With this script, I get data from JsonResult (GetDevicesTable) and put it in a table (id = "OrderDevices")
<script type="text/javascript">
$(document).ready(function() {
$("#getDevices a").click(function() {
var Id = $(this).attr("rel");
var rowToMove = $(this).closest("tr");
$.post("/ImportXML/GetDevicesTable", { Id: Id }, function(data) {
if (data.success) {
rowToMove.fadeOut(function() { $(this).remove() });
$("#OrderDevices").append("<tr><td>"+ data.DeviceId+ "</td><td>" + data.Id+ "</td><td>" + data.OrderId + "</td></tr>");
} else {
alert(data.ErrorMsg);
}
}, "json");
});
});
<% using (Html.BeginForm()) {%>
<table id="OrderDevices" class="data-table">
<tr>
<th>
DeviceId
</th>
<th>
Id
</th>
<th>
OrderId
</th>
</tr>
</table>
<p>
<input type="submit" value="Submit" />
</p>
<% } %>
When I click Submit, I need something like this:
$(document).ready(function() {
$("#submit").click(function() {
var Id = $(this).attr("rel");
var DeviceId = $(this).attr(???);
var OrderId = $(this).attr(???);
var rowToMove = $(this).closest("tr");
$.post("/ImportXML/DevicesActions", { Id: Id, DeviceId:DeviceId, OrderId:OrderId }, function(data) {
}, "json");
});
});
I have a problem with this script because I don't know how the mail data for this JsonResult is:
public JsonResult DevicesActions(int Id,int DeviceId,int OrderId)
{
orderdevice ord = new orderdevice();
ord.Id = Id;
ord.OrderId = DeviceId;
ord.DeviceId = OrderId;
DBEntities.AddToorderdevice(ord);
DBEntities.SaveChanges();
}
source
share