有了這個劇本我從JsonResult(GetDevicesTable)數據初學者的問題,並把他們的表(ID = 「OrderDevices」)與發佈數據表JsonResult
<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) {
//remove row
rowToMove.fadeOut(function() { $(this).remove() });
//add row to other table
$("#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>
<% } %>
當點擊在提交我需要這樣的事情:
$(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");
});
});
我有這個腳本的問題,因爲不知道如何發佈數據到這個JsonResult:
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();
}
當您點擊提交按鈕時,您想使用哪個'Id','DeviceId'和'OrderId'?已經插入最後一個表格行的那個? – 2010-05-20 07:07:26
我想要所有的(Id,deviceId和OrderId)。他們需要在JsonResult DevicesActions – Ognjen 2010-05-20 07:16:28
我需要在JsonResult中發佈所有表格行 – Ognjen 2010-05-20 07:17:08