Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i call/request a .net handler (ashx) using javascript?

Is it possible to call a handler using javascript code? e.g. i have a handler deployed at this location http://mysitename.com/getMyData.ashx. Can I call this handler or just request it using javascript? Is it even possible or not? Please suggest.

like image 432
ria Avatar asked Jul 20 '26 01:07

ria


1 Answers

yes you can

use ajax or jquery ajaxcall for this.

same ajax function :

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();
}
like image 55
Pranay Rana Avatar answered Jul 22 '26 13:07

Pranay Rana