using web methods with master pages

后端 未结 3 1037
春和景丽
春和景丽 2021-01-05 01:24

I\'ve got a function on all pages in my site which is located in my master page and I want it to run from some jQuery Ajax method.

I\'ve got some code like this at t

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-05 01:48

    You can go the Base Class method route, as Andreas mentioned above.

    Make sure:

    • The webmethod is static.
    • In your Ajax call, dynamically change the URL based on the page you are viewing. Something like this:

    (in Ajax call:)

    url: window.location.pathname.substr(1) + "/GetDate"
    

提交回复
热议问题