Calling an ASP.NET server side method via jQuery
To call ASP.NET AJAX "ScriptServices" and page methods, you need to use the full $.ajax() syntax:
$.ajax({ type: "POST", url: "MessagePopup.aspx/SendMessage", data: "{subject:'" + subject + "',message:'" + message + ",messageId:'" + messageId + "',pupilId:'" + pupilId +"'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { // Do something interesting here. }});
See this post for details on why that's necessary: http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/
Edit: The extension doesn't change to .asmx but remains .aspx.
It looks like you're trying to make use of a page method.
Take a look here Page Methods in ASP.NET Ajax for help
You should use web service instead of regular aspx web page. Web pages has no support to call web methods, I believe your jQuery request loads the HTML page instead. I suggest you two things:
- Use Fiddler2 (with IE) or HttpFox (with Firefox) to debug AJAX requests and responses on client side.
- Use WCF web service on the server side. in this case you can use SvcConfigEditor and SvcTraceViewer to configure and debug web methods on the server side.