使用Asp.Net 4.0 Web窗體和Jquery 1.6.2。 我想對頁面上的WebMethod進行Ajax調用,並讓它返回html。 在服務器端WebMethod看起來像這樣。如何使用Jquery從ASP.Net WebMethod調用返回HTML?
[WebMethod]
public static string GetOrders()
{
return theMethodThatGeneratesHtml();
}
這裏是調用Ajax函數。
function GetOrders()
{
$.ajax({
type: 'POST',
contentType: "application/json",
url: "Orders.aspx/GetOrders",
data: "{}",
success: function (data) {
$('#content').html(data);
},
dataType: "text"
});
}
是從將WebMethod返回的數據總是被包裹起來作爲開始這樣的JSON對象。
{"d":"\u003ctable\u003e\r\n ........
如何才能讓WebMethod只返回HTML?