1

我有一个函数,它为某些服务器操作调用通用处理程序,并且在处理程序完成后,我想根据服务器端发生的情况将消息传递给 ajax 成功函数。

有可能做到这一点,我该怎么做?

这就是我的想法

$(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

    }

});

这是处理程序

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             

    }

谢谢

4

1 回答 1

1

将字符串写入您的 processrequest 方法中的响应对象:

context.Response.Write(message);
于 2013-08-09T14:05:40.820 回答