1
我嘗試了通過JSON或jQuery的Ajax獲得來自web服務雙數據表像如何使用json或jquery獲得雙重對象?
WebService的方法:
[WebMethod]
public DataSet FareAccpted_(string custId)
{
DataSet ds = new DataSet();
List<fareAccptedList> details = new List<fareAccptedList>();
using (SqlConnection con = new SqlConnection("..."))
{
using (SqlCommand cmd = new SqlCommand("proc_FareAcceptedC", con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@customerId", SqlDbType.Int).Value = custId;
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
}
}
return ds;
}
JS的頁面:
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "../lpService.asmx/FareAccpted_",
data: JSON.stringify({ custId: custId_ }),
dataType: "json",
success: function (data) {
alert('Length : '+data.d.length)
},
error: function (result) {
alert("FareAcceptedC" + "Error");
}
});
在DataSet中的DataTable商店。
你試過和......發生了什麼?請添加更多的細節。有什麼問題?服務是做什麼的?你想達到什麼目的? –
嗨薩米,thanx您的寶貴迴應,我再次妥善編輯我的問題,你可以看到並幫助我,Thanx提前:) –