Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

call web methods from ajax in episerver

Vote:
 

Hi.

I have search page template which have web method. So i create in admin mode search page (mysite.com/search/)

So how I can call from ajax her web method?

PS: In standart asp.net web from I can call web method like this

$.ajax({
  type: "POST",
  url: "PageName.aspx/MethodName",
  data: "{}",
  contentType: "application/json; charset=utf-8",
  dataType: "json",
  success: function(msg) {
    // Do something interesting here.
  }
});
which url I must use for call web method in Epriserve page templete
#70186
Apr 13, 2013 13:57
Vote:
 

Maybe someone else may have an idea or practice of how to work with ajax call in episerver?

because I still can not call my web method...

#70193
Apr 14, 2013 13:33
Vote:
 

Doesn´t /search/mymethod work? You also need the WebMethodAttribute decorated on your method. If that does´t work make sure ASP.NET Ajax is working correctly by creating a simple web forms .aspx that inherits from Page with a simple method with the WebMethodAttribute that you can call like any other .aspx (/mytest.aspx/mymethod).

Frederik

#70199
Apr 14, 2013 20:59
Vote:
 

So it doesnt work because my url is not correct.. on search page mysite/search/ and url in ajax is

Views/Pages/SearchPageTemplate.aspx/MyMethod..

So when I clicked url is mysite/search/Views/Pages/SearchPageTemplate.aspx/MyMethod it wrong, correct url is

mysite/Views/Pages/SearchPageTemplate.aspx/MyMethod.

I need instance + "Views/Pages/SearchPageTemplate.aspx/MyMethod". Maybe You can prompt how to get instance ?


Thanks in advance.

#70201
Apr 14, 2013 22:16
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.