用ajax VS下调试正常iis下不起作用
JS主要函数:function GetInfo(str){//我们就是通过这个函数来异步获取信息的
var xmlHttpReq = null;//声明一个空对象用来装入XMLHttpRequest
if (window.XMLHttpRequest){//除IE5 IE6 以外的浏览器XMLHttpRequest是window的子对象
xmlHttpReq = new XMLHttpRequest();//我们通常采用这种方式实例化一个XMLHttpRequest
}
else if (window.ActiveXObject){//IE5 IE6是以ActiveXObject的方式引入XMLHttpRequest的
xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
//IE5 IE6是通过这种方式
}
if(xmlHttpReq != null){//如果对象实例化成功 我们就可以干活啦
var xsy = encodeURIComponent(document.getElementById("xsy").value);
var mcdz = encodeURIComponent(document.getElementById("mcdz").value);
var jxs = encodeURIComponent(document.getElementById("jxs").value);
var lxfs = encodeURIComponent(document.getElementById("lxfs").value);
var xm = encodeURIComponent(document.getElementById("xm").value);
var dh = encodeURIComponent(document.getElementById("dh").value);
var dnxh = encodeURIComponent(document.getElementById("dnxh").value);
var sn = encodeURIComponent(document.getElementById("sn").value);
var cs = encodeURIComponent(document.getElementById("cs").value);
var xb = encodeURIComponent(document.getElementById("xb").value);
//xmlHttpReq.open("get","AjaxTest.aspx?s="+str+"&xsy="+xsy+"&mcdz="+mcdz+"&jxs="+jxs+"&lxfs="+lxfs+"&xm="+xm+"&dh="+dh+"&dnxh="+dnxh+"&sn="+sn+"&cs"+cs+"&xb"+xb,true);
xmlHttpReq.open("get","AjaxTest.aspx?s="+str+"&sn="+sn+"&xm="+xm+"&dnxh="+dnxh+"&dh="+dh+"&xb="+xb+"&mcdz="+mcdz+"&jxs="+jxs+"&cs="+lxfs+"&cs"+xsy+"&lxfs"+lxfs,true);
//调用open()方法并采用异步方式
//xmlHttpReq.onreadystatechange=RequestCallBack; //设置回调函数
xmlHttpReq.send(null);//因为使用get方式提交,所以可以使用null参调用
}
function RequestCallBack(){//一旦readyState值改变,将会调用这个函数
if(xmlHttpReq.readyState == 4)
{
// document.getElementById("xsy").value = xmlHttpReq.responseText;
//将xmlHttpReq.responseText的值赋给iptText控件
}
}
}
aspx.cs内主要函数
public partial class AjaxTest : System.Web.UI.Page
{
string s="";
string sn="";
string xm="";
string xb = "";
string dnxh="";
string dh="";
string xsy= "";
string mcdz="";
string jxs="";
string lxfs="";
string cs = "";
protected void Page_Load(object sender, EventArgs e)
{
s=this.Request.QueryString["s"];
if (s=="1"|| s=="2"|| s=="3" || s=="4")
{
//如果去掉这句 会得到多余的HTML代码
//excel操作
//建立Application对象
Microsoft.Office.Interop.Excel.Application myExcel = new Application();
//建立Workbooks对象
Workbooks myBooks = myExcel.Application.Workbooks;
//建立一个System.Reflection.Missing的object对象
object missing = System.Reflection.Missing.Value;
//打开Excel文件,注意里的“ExccelFilePath”为Excel文件在服务器上的物理地址,包括文件名
Workbook myBook = myBooks.Open(@"D:\001.xls", missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
//Workbook myBook = myBooks.Open(@"D:/001.xls", Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing);
//新建Workseet对象,,此处为要操作的工作表 ,当前要操作的工作表的获取方法有两种:使用工作表的索引值或使用工作表的名称,名称默认为:“sheet1”/“Sheet2”等
Worksheet mySheet = (Worksheet)myBook.Worksheets[1];
////如果是新建EXCEL工作簿,需要 设置如下两行内容,以保证工作簿中有一个工作表,
//Workbook workbook1 = excel1.Workbooks.Add(true);
//Worksheet mySheet = (Worksheet)workbook1.Worksheets["sheet1"];
//设置EXCEL对象是否显示界面,默认为false不显示界面
myExcel.Visible = true;
int rowsint = mySheet.UsedRange.Cells.Rows.Count;
mySheet.Cells[rowsint, 2] = s;
myBook.Save();
myBooks.Close();
myExcel.Quit();
}//转盘抽奖结果写入结束
//我要抽奖div转换
if (s=="5")
{
sn = this.Request.QueryString["sn"];
xm = this.Request.QueryString["xm"];
xb = this.Request.QueryString["xb"];
dnxh = this.Request.QueryString["dnxh"];
dh = this.Request.QueryString["dh"];
mcdz = this.Request.QueryString["mcdz"];
jxs = this.Request.QueryString["jxs"];
lxfs = this.Request.QueryString["lxfs"];
xsy = this.Request.QueryString["xsy"];
cs = this.Request.QueryString["cs"];
//如果去掉这句 会得到多余的HTML代码
//excel操作
//建立Application对象
Microsoft.Office.Interop.Excel.Application myExcel = new Application();
//建立Workbooks对象
Workbooks myBooks = myExcel.Application.Workbooks;
//建立一个System.Reflection.Missing的object对象
object missing = System.Reflection.Missing.Value;
//打开Excel文件,注意里的“ExccelFilePath”为Excel文件在服务器上的物理地址,包括文件名
Workbook myBook = myBooks.Open(@"D:\001.xls", missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
//Workbook myBook = myBooks.Open(@"D:/001.xls", Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing);
//新建Workseet对象,,此处为要操作的工作表 ,当前要操作的工作表的获取方法有两种:使用工作表的索引值或使用工作表的名称,名称默认为:“sheet1”/“Sheet2”等
Worksheet mySheet = (Worksheet)myBook.Worksheets[1];
////如果是新建EXCEL工作簿,需要 设置如下两行内容,以保证工作簿中有一个工作表,
//Workbook workbook1 = excel1.Workbooks.Add(true);
//Worksheet mySheet = (Worksheet)workbook1.Worksheets["sheet1"];
//设置EXCEL对象是否显示界面,默认为false不显示界面
myExcel.Visible = true;
int rowsint = mySheet.UsedRange.Cells.Rows.Count;
mySheet.Cells[rowsint + 1, 1] = sn;
mySheet.Cells[rowsint + 1, 3] = xm;
mySheet.Cells[rowsint + 1, 4] = dnxh;
mySheet.Cells[rowsint + 1, 5] = dh;
mySheet.Cells[rowsint + 1, 6] = xb;
mySheet.Cells[rowsint + 1, 7] = mcdz;
mySheet.Cells[rowsint + 1, 8] = jxs;
mySheet.Cells[rowsint + 1, 9] = lxfs;
mySheet.Cells[rowsint + 1, 10] = xsy;
mySheet.Cells[rowsint + 1, 11] = cs;
myBook.Save();
myBooks.Close();
myExcel.Quit();
}
}
} C# 调试 ajax iis 服务器 --------------------编程问答-------------------- 太长了,是服务器端调试?还是客户端调试,如果是客户端,跟你的游览器相关 --------------------编程问答-------------------- 服务器就调试不通
补充:.NET技术 , .NET Framework