私はjqueryからWebメソッドを呼び出しています。データベースの処理を正しく実行し、文字列を返す必要があります。そして、Jqueryでは、返された文字列を取得して、Panelオブジェクトに表示したいと思います。しかし、文字列を取得できず、パネルに表示できません
注:パネルにアクセスする方法は正しいです。これは機能します$('#<%= 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";
}