0
我从jquery调用了一个web方法,它正确地执行了一些数据库内容,然后它应该返回一个字符串。在Jquery中,我想获取返回的字符串并将其显示在Panel对象中。但我无法获取字符串,也无法在面板中显示它ASP.Net jQuery从Web方法返回数据
注意:我访问面板的方式是正确的。这个作品$('#<%= pnl_poll_result.ClientID%>')。text(“some string”);
这里是代码,
$.ajax({
type: "POST",
url: "ViewPost.aspx/insert_post_poll_selections",
data: "{'ProfessionalId':'1','choice_id':'" + $('#<%=rbl_poll.ClientID %> input:checked').val() + "','PostId':'<%=Session["SessionPostId"].ToString() %>','UserId':'<%=Session["SessionUserId"].ToString() %>'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
$('#<%=pnl_poll_result.ClientID %>').text(data);
}
});
这里是将WebMethod
[WebMethod]
public static String insert_post_poll_selections(String ProfessionalId, String choice_id, string PostId, string UserId)
{
//do some database stuff
return "return message from web method";
}
我检查了控制台,它没有抛出任何异常。奇怪的 –
我将代码更改为此警报(data.responseText);并显示“undefined” –
现在它返回“[object Object]” –