i cant access to SayHello.ashx and i got this javascript error :
httpReq.open is not a function.
but the code work fine when i use an aspx page for answer xmlhttprequest :
httpReq.open("POST", "SayHello.aspx");
where is the problem? can the problem be from my .ashx file ?
function callASHX() {
var httpReq=XMLHttpRequest();
var x = document.getElementById('txtName').value;
var sendStr = "user_id=" + x;
httpReq.open("POST", "SayHello.ashx");
httpReq.onreadystatechange = XMLHttpRequestCompleted;
httpReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
httpReq.send(sendStr);
}
// initialize XMLHttpRequest object
function XMLHttpRequest() {
var httpReq;
try {
// Opera 8.0+, Firefox, Safari
httpReq = new XMLHttpRequest();
}
catch (e) {
// IEBrowsers
try {
httpReq = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
httpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
return false;
}
}
}
return httpReq;
}