Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
how to use call back function in Jquery Get method for Ajax call ,
as i want to fetch a boolean or numeric variable value from my aspx.cs page in .aspx
Page??


Pls help ..thanks in advance

additional information copied from comment below
this is my Get Function for ajax calling in Jquery--

C#
function SetID(ID) 
         {
             //debugger;
             var strID = "#" + ID;
             var IsSelected = true;
             var temp2 = $(strID)[0].value;
             $.get('Dynamic_page.aspx', { Id: ID, Mode: $(strID)[0].value, XYZ: IsSelected }, function() {             
             //alert("");

         });
Posted
Updated 3-Mar-13 5:44am
v2
Comments
sr_24 3-Mar-13 10:55am    
this is my Get Function for ajax calling in Jquery--

function SetID(ID)
{
//debugger;
var strID = "#" + ID;
var IsSelected = true;
var temp2 = $(strID)[0].value;
$.get('Dynamic_page.aspx', { Id: ID, Mode: $(strID)[0].value, XYZ: IsSelected }, function() {
//alert("");

});

1 solution

In your code behind page, create a static Web method
C#
[WebMethod]
public static string MyPageMethod(string myInputParameter) 
{ 
// SNIP
}

In your aspx page, enable Page methods
ASP.NET
<asp:scriptmanager id="MyScriptManager" runat="server" EnablePageMethods="true" />

In your javascript, call the page method (As you are using ASP.Net, you can take advantage of the PageMethods function. Pass in your input parameter(s) and then the function that should be executed when the method returns. Also, you can have a function for failures (after the success function)
JavaScript
var strID = "#" + ID;
PageMethods.MyPageMethod(strID, MyPageMethodFunctionResultSuccess);

function MyPageMethodFunctionResultSuccess(result)
{
    // result is the string returned from the server
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900