Net-informations.com
SiteMap  | About    

Calling ASP.Net Code Behind using jQuery AJAX



With the help of the $.ajax() we can able to call the web method which is defined in the C# class . From the following example, the $.ajax() function will make asynchronous HTTP(Ajax) request to the web method called as getOutput().

jQuery Source Code

Here we are specifying success: and failure: to show the kind of return data format we are expecting from the web method.

success: function (response)

On successful execution of the requested web method the ajax function will call the method to process the output.

Failure:Function(responce)

Failure method gets executed when there is some exception happens on web method execution.

C# Source Code

It is important to note that, when we call a C# function in code-behind , the function must be defined as a static function, otherwise the ajax function cannot call it.










net-informations.com (C) 2019    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.