When I try to access web method I obtain error:
PageMethods.GetRate is not a function;
My method:
[WebMethod]
开发者_运维知识库 [ScriptMethod]
public static string GetRate(string date)
{
return "qwe123";
}
Register assembly:
<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="aspajax" %>
Script manager:
<aspajax:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" />
Javascript:
<script type="text/javascript">
function OnGetRateComplete(result)
{
alert(result);
}
$(function() { $( "#<%=dtSignDate.ClientID %>" ).datepicker({ onSelect: function(date) { PageMethods.GetRate(date, OnGetRateComplete); }}); });
</script>
GetRate method is visible in generated page source.
What is wrong?
Did you make sure you applied the ScriptService attribute to your web service? i.e.
[ScriptService]
public class WebService : System.Web.Services.WebService
well,u want to deal with ajax,then use $.ajax() is a good simple way to request the WebMethod. take a look at this question, u will get help
request url is [XX.aspx/GetRate], method:[POST]
精彩评论