weixin_33739541 2014-02-28 07:45 采纳率: 0%
浏览 51

PageMethod与Ajax异步调用

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);
  • 写回答

2条回答 默认 最新

  • weixin_33726318 2014-02-28 08:01
    关注

    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.
      }
    });
    
    评论

报告相同问题?