[英]How do you call an 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 the JavaScript. 我想调用ASHX文件并从JavaScript传递一些查询字符串变量,并将返回字符串转换为JavaScript中的字符串。 How would I do this?
我该怎么做?
The ASHX file is already coded to response.write a string based on whatever the query strings are. ASHX文件已经编码为response.write一个基于查询字符串的字符串。
Something like this?: 像这样的东西?:
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;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.