1
我正在使用缓存服务器页面(Intersystems)并尝试通过JavaScript调用ASHX,但它不起作用。Intersystems缓存 - 使用缓存服务器页面(Intersystems)通过javascript调用ASHX
如何在缓存服务器页面中调用用c#编写的ashx?
我试图使用下面的方法。
InterSystems的缓存
Class ArithematicMean.MeanPage Extends %CSP.Page
{
ClassMethod OnPage() As %Status
{
&html<<html id="arithematicmean">
<head>
<script type="text/javascript" src="external_javascript.js"></script>
<script type="text/javascript" src="MeanCalculation.js"></script>
</head>
<body>
<script language='javascript'>
function mean(array)
{
var Mean = 0, N = 0, MeanPrev = 0, Sum=0, p;
for(var i = 0; i < array.length; i++)
{
++N;
p = parseFloat(array[i]);
if (!isNaN(p)) Sum += p;
MeanPrev = Mean;
Mean += (array[i] - MeanPrev)/N;
}
alert (Sum);
alert(Mean ? Math.round(Mean*10)/10 : 0);
}
var httpReq = null;
function InstructionsImageASHX()
{
httpReq = XMLHttpRequest();
httpReq.open("GET", "InstructionsImage.ashx", true);
alert('hi123');
httpReq.onreadystatechange = XMLHttpRequestCompleted;
httpReq.send(null);
}
// initialize XMLHttpRequest object
function XMLHttpRequest() {
var xmlHttp;
try {
// Opera 8.0+, Firefox, Safari
xmlHttp = new XMLHttpRequest();
}
catch (e) {
// IEBrowsers
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
return false;
}
}
}
return xmlHttp;
}
function XMLHttpRequestCompleted()
{
if (httpReq.readyState == 4)
{
try
{
alert(httpReq.responseText);
}
catch (e)
{
}
}
}
</script>
<center>
<h1> Sum and Arithemetic Mean Calculation for 3 Numbers</h1>
</center>
<table cellpadding="5">
<tr>
<td width="20%">
</td>
<td width="20%">
<label name="lblnumone"> Value One</label>
</td>
<td width="20%">
<input type="text" name="txtnumone" id="txtnumone" runat="server" width="10"/>
</td>
</tr>
<tr>
<td width="20%">
</td>
<td width="20%">
<label name="lblnumtwo"> Value Two</label>
</td>
<td width="20%">
<input type="text" name="txtnumtwo" id="txtnumtwo" runat="server" width="21"/>
</td>
</tr>
<tr>
<td width="20%">
</td>
<td width="20%">
<label name="lblnumthree"> Value Three</label>
</td>
<td width="20%">
<input type="text" name="txtnumthree" id="txtnumthree" runat="server" width="21"/>
</td>
</tr>
<tr>
<td width="20%">
</td>
<td width="20%">
<button id="btnInstructionsImage" onclick= 'InstructionsImageASHX();'>Instructions in Image</button>
</td>
<td width="20%">
<button id="btnCalculate" onclick='alert(mean([document.getElementById("txtnumone").value,document.getElementById("txtnumtwo").value,document.getElementById("txtnumthree").value]));'>Calculate Mean</button>
</td>
<td width="20%">
<img src="InstructionsImage.ashx" height="100" width="200">
</td>
</tr>
</table>
</body>
</html>>
Quit $$$OK
}
}
CSP与asp.net几乎完全相同的架构角色。那么,你们两个都用?在您的示例中,我实际上没有看到您使用CSP的任何标志。 – psr 2013-02-26 18:10:38
CSP没有太多的代码。 我想用png,doc和pdf格式生成文本,并且我想为每个文件使用ASHX。例如,如果我们为png单击一个按钮,那么文本将分别以png格式显示。 – Sun 2013-02-27 01:05:25
所以你有一些CSP页面提供了一些完全静态的HTML文件,然后你想使用javascript调用asp.net中的ASHX页面?如果是这样,你可能会删除缓存和csp标签,因为他们所做的只是提供一个静态文件。假设你的Web服务器设置了CSP和asp.net,并且没有CSP可以直接处理ASHX文件的印象。 – psr 2013-02-27 01:44:28