Sending parameters to jquery callback

Posted by KhanS on Stack Overflow See other posts from Stack Overflow or by KhanS
Published on 2010-06-08T08:20:35Z Indexed on 2010/06/08 8:22 UTC
Read the original article Hit count: 289

Filed under:
|
|

I am making a jquery call from a javascript method. I want a parameter to be sent to my call back method. I am using a handler(ashx) to make jquery call, the handler is getting invoked by the callback is not getting fired. Below is the code

function MyButtonClick(){
var myDiv = "divname";
$.post("MyHandler.ashx", { tgt: 1 }, myDiv, CustomCallBack);
}

function CustomCallBack(data, result) {
        debugger;
        //SomeCode
    }
}

Handler code(ashx file)

public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            int tgt = Convert.ToInt32(context.Request["tgt"]);
            if (tgt == 1)
            {
                          context.Response.Write("Some text");
            }
        }

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET