What do you call ASHX from JavaScript?

I want to call an ASHX file and pass some query string variables from JavaScript and get the return string into a string in JavaScript. How can I do it?

The ASHX file is already encoded for the response.write line based on any request lines.

+3
source share
1 answer

Something like that?:

function createXMLHttpRequest() {
   try { return new XMLHttpRequest(); } catch(e) {}
   try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
   alert("XMLHttpRequest not supported");
   return null;
 }

var xmlHttpReq= createXMLHttpRequest();
xmlHttpReq.open("GET", "your.ashx?v1=1&v2=2&etc", false);
xmlHttpReq.send(null);
var yourJSString = xmlHttpReq.responseText;
+10
source

Source: https://habr.com/ru/post/1702778/


All Articles