I am new asp.net and want to call server side method from java script. For that I can do this using ajax call and PageMethod.
Now my question is which one is better to use?
$.ajax({})
Or
PageMethods.FunctionName(Parameter);
No one can tell better than Dave Ward
http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/
Page methods are much more openly accessible. The relative unimportance of EnablePageMethods is a nice surprise.
$.ajax({
type: "POST",
url: "PageName.aspx/MethodName",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
// Do something interesting here.
}
});
if you have already put Ajax scrip manager. you can user any method. but if you have not put script manager i suggest you should go for Ajax asynchronous call
Page methods are much more openly accessible.and it is not good idea to put script manager just for web method calling