Каждый раз, когда я пытаюсь связать таблицы данных из webmethod веб-формы, оповещение отвечает на мою ошибку. Предупреждение DataTables: table id = abc - Ajax error. Для получения дополнительной информации об этой ошибке см. http://datatables.net/tn/7
Я пытался посетить http://datatables.net/tn/7, но не нашел решения.
веб-метод:
[WebMethod]
public static string GetWorkOrders()
{
string constr = ConfigurationManager.ConnectionStrings["connection"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("SELECT sc.CompanyName AS Sender, rc.CompanyName AS Receiver, pl.PickDropLocationName AS PULocation, dl.PickDropLocationName AS DOLocation FROM WorkOrder wo INNER JOIN Company sc ON sc.CompanyID = wo.SenderCompany INNER JOIN Company bc ON bc.CompanyID = wo.BillToCompany INNER JOIN Company rc ON rc.CompanyID = wo.ReceiverCompany INNER JOIN PickDropLocation pl ON pl.PickDropID = wo.PickupLocation INNER JOIN PickDropLocation dl ON dl.PickDropID = wo.DropoffLocation"))
{
cmd.Connection = con;
DataSet ds = new DataSet();
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
sda.Fill(ds, "WorkOrders");
}
return ds.GetXml();
}
}
}
ajax call:
$('#abc').DataTable({
ajax: {
url: "WorkOrder.aspx/GetWorkOrders",
contentType: "application/json; charset=utf-8",
type: "POST",
"datatype": "json",
dataSrc: "WorkOrders"
},
"columns": [
{ data: "Sender" },
{ data: "Receiver" },
{ data: "PULocation" },
{ data: "DOLocation" }
],
"bDestroy": true,
"serverSide": true,
"pageLength": 25,
"processing": true,
"searching": false,
"bSort": false,
});
html:
<table id="abc">
<thead>
<tr>
<th>Sender</th>
<th>Receiver</th>
<th>Pickup</th>
<th>Dropoff</th>
</tr>
</thead>
</table>