I am calling a web method from jquery, It does some database stuff correctly, then it should return a string. And in Jquery, I want to get that returned string and display it in a Panel object. But I cannot get the string and cannot display it in the Panel
NOTE: The way I am accessing the Panel is correct. this works $(‘#<%=pnl_poll_result.ClientID %>’).text(“some string”);
here is the code,
$.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);
}
});
here is the 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";
}
I think you should debug your code in console in webbrowser to look what contains data variable. Maybe solution is simple, and you should use