Question

I have a function that calls a generic handler for some server action and upon completion of the handler I want to pass a message to the ajax success function based on what happened server side.

is it possible to do this and how can I do this?

this is what I have in mind

$(document).on("click", "input[name='chkUserStreaming']", function () {

var prodKeyStream = $("input[name='prodKeyStream']").val();

$.ajax({
    url: 'Handlers/StreamingForUser.ashx',
    data: { 'prodKeyStream': prodKeyStream },
    success: function (data) {

        //here is where I want an alert message based on the value passed from
        //handler

    }

});

here is the handler

public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        bool success;//true or false which I want to pass to the call back
        var prodKeyStream = context.Request["prodKeyStream"].ToString();


        //server side action, from here I want to pass a varaible(message)
        //to ajax success callback             

    }

Thank you

Was it helpful?

Solution

Write the string to the response object in your processrequest method:

context.Response.Write(message);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top