如何使用javascript读取response.write值 [英] How to read the response.write value using javascript

查看:671
本文介绍了如何使用javascript读取response.write值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<%
dim fs
set fs = Server.CreateObject( Scripting.FileSystemObject
if fs.FolderExists( D:\\\\\\\\\\ java.txt)= true 然后
response.write( < span class =code-string>文件夹c:\ asp存在!)
else
response.write( 文件夹c:\ asp不存在!
end if
set fs = nothing
%>









我有一个带有以下代码的asp文件,现在我想使用javascript读取response.write的值。

解决方案

在页面中添加标签或隐藏字段,然后在C#中设置它的值。然后在JavaScript中,您可以使用document.getElementById()或jquery来获取值。


假设此页面的名称是 IsFoderExists.asp

<![CDATA [<%
dim fs
set fs = Server.CreateObject( Scripting.FileSystemObject
if fs.FolderExists( D:\ java /\\ x.java。 txt)= true 然后
response.write( 文件夹c:\ asp存在!
else
response.write( 文件夹c:\ asp不存在!
结束 如果
设置 fs =没有
%>





写javascript来调用此页面...

 function IsFolderExists()
{
if (window.XMLHttpRequest)
{ // IE7 +的代码,Firefox, Chrome,Opera,Safari
xmlhttp1 = new XMLHttpRequest();
}
其他
{ // IE6代码,IE5
xmlhttp1 = ActiveXObject( Microsoft.XMLHTTP);
}
xmlhttp1.onreadystatechange = function()
{
if (xmlhttp1.readyState == 4 && xmlhttp1.status == 200
{
响应。 write(xmlhttp1.responseText);
//


< 。BLOCKQUOTE>( '#DIV1')HTML(xmlhttp1.responseText); //你可以在div中显示响应。
}
}
xmlhttp1.open( GET IsFolderExists.asp true );
xmlhttp1.send();
return false ;
}



快乐编码!

:)


<%
dim fs
set fs=Server.CreateObject("Scripting.FileSystemObject")
if fs.FolderExists("D:\java\x.java.txt")=true then
  response.write("Folder c:\asp exists!")
else
  response.write("Folder c:\asp does not exist!")
end if
set fs=nothing
%>





I have a asp file with the following code , Now i want to read the value of response.write using javascript .

解决方案

Add a label or hidden field to your page then in C# set it's value. Then in JavaScript you can use document.getElementById() or jquery to get the value.


suppose name of this page is IsFoderExists.asp

<![CDATA[<%
dim fs
set fs=Server.CreateObject("Scripting.FileSystemObject")
if fs.FolderExists("D:\java\x.java.txt")=true then
  response.write("Folder c:\asp exists!")
else
  response.write("Folder c:\asp does not exist!")
end if
set fs=nothing
%>



write javascript to call this page...

function IsFolderExists()
    {
        if (window.XMLHttpRequest)
        {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp1=new XMLHttpRequest();
        }
        else
        {// code for IE6, IE5
            xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp1.onreadystatechange=function()
        {
            if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
            {
                response.write(xmlhttp1.responseText);
//


('#div1').html(xmlhttp1.responseText); // you can display response in div. } } xmlhttp1.open("GET","IsFolderExists.asp",true); xmlhttp1.send(); return false; }


Happy Coding!
:)


这篇关于如何使用javascript读取response.write值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆