Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我可以使用javascript调用/请求.net处理程序(ashx)吗?_.net_Asp.net_Javascript_Handler - Fatal编程技术网

我可以使用javascript调用/请求.net处理程序(ashx)吗?

我可以使用javascript调用/请求.net处理程序(ashx)吗?,.net,asp.net,javascript,handler,.net,Asp.net,Javascript,Handler,是否可以使用javascript代码调用处理程序?e、 我在这个位置部署了一个处理程序。我可以调用这个处理程序还是使用javascript请求它?到底有没有可能?请建议。是的,你可以 为此使用ajax或jquery ajaxcall 相同的ajax功能: function showHint(elementid,url,str) { if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else

是否可以使用javascript代码调用处理程序?e、 我在这个位置部署了一个处理程序。我可以调用这个处理程序还是使用javascript请求它?到底有没有可能?请建议。

是的,你可以

为此使用ajax或jquery ajaxcall

相同的ajax功能:

function showHint(elementid,url,str) {

    if (window.XMLHttpRequest) {
        xmlhttp=new XMLHttpRequest();
    } else {
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 && xmlhttp.status==200) {
            document.getElementById(elementid).innerHTML=xmlhttp.responseText;
        }
    }
    xmlhttp.open("GET",url+str,true);
    xmlhttp.send();
}

您可以使用XMLHttpRequest(AJAX,不一定使用XML)在后台加载URL。
我强烈建议您通过像jQuery这样的javascript框架来实现这一点,因为这样可以避免您直接访问丑陋的低级界面。

首先,请详细说明您想要做什么


您可以使用AJAX调用它并请求webservice URL。

我应该在str变量中添加什么???我已将url放在url变量中。如果不想传递任何查询字符串数据,可以传递emptystring实际上我传递了一个空字符串,但我认为没有执行此语句:document.getElementById(elementid)。innerHTML=xmlhttp.responseText;我甚至在这里放了一个警告声明,但它不起作用。可能是什么问题?检查处理程序代码是否使用以下语句写入数据:HttpContext.Current.Response.Write以在ProcessRequest函数中写入数据其他一切都正常还检查elementid,即具有此id的元素是否存在谢谢。。。实际上,我以前从来没有这样做过,所以我想要一个示例代码段:)
$(document).ready(function () {
        saveCookies('true');
    });

function saveCookies(save) {
        $.ajax({
            url: "/Handlers/getMyData.ashx.ashx",
            data: { 'savecookies': save },
           async: false,
            success: function (data, status, xhr) {   
            }
        });
    };