我想调用ASHX文件并从JavaScript传递一些查询字符串变量,并将返回字符串转换为JavaScript中的字符串.我该怎么做?
ASHX文件已经编码为response.write一个基于查询字符串的字符串.
像这样的东西?:
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;