【问题标题】:How to return a value from .ashx file to javascript in a variable如何将 .ashx 文件中的值返回到变量中的 javascript
【发布时间】:2012-04-10 07:01:37
【问题描述】:

我正在从 javascript 调用 ashx 文件。 Http Handler 文件返回字符串值。

context.response.write(string value);


<script type="text/javascript">
$(window).load(function(){

$('area').each(function () {       
    var area = $(this),

alt = area.attr('id');
if (alt != null) {

                area.mouseenter(function () {
                    $('#dhtmltooltip').load("Search_CS.ashx?q=" +alt);
                    ddrivetip('', 300);
                }).mouseleave(function () {
                    $('#dhtmltooltip').html('');
                    hideddrivetip();
                });
            }

        });

我必须在 javascript 的变量中接收这个字符串。

如何做到这一点?

【问题讨论】:

  • 你控制 HttpHandler 吗?它设置/返回什么内容类型?

标签: javascript httphandler ashx


【解决方案1】:

我猜你没有发出任何 ajax 请求。这page 有帮助吗? 有一个名为“insertCustomerCallback”的函数调用,它将从处理程序返回 html。在那里你需要编写你的代码。 例如,

function insertCustomerCallback(html) {
//write your code
}

【讨论】:

    猜你喜欢
    • 2013-04-24
    • 1970-01-01
    • 2016-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    相关资源
    最近更新 更多