for working with
getAllMessages()
You need to create Web Api function by
create a new Message.svc file under Root directory with below,
[WebMethod]
[WebInvoke(Method = "Get", ResponseFormat = WebMessageFormat.Json)]
public IEnumerable<Messages> GetAllMessage()
{
}
under Messages.aspx
function getAllMessages()
{
$.ajax({
type: "Get",
contentType: "application/json; charset=utf-8",
data: null,
url: "Message.svc/GetAllMessage",
dataType: "json",
processData: false,
success: function (result) {
$("#messagesTable").empty();
$.each(result, function(key, item){
$("#messagesTable").append("<div>" + item.Message + "</div>");
});
},
error: function (e) {
alert("Failed on :" + e.status + " with:" + e.statusText);
}
});
}