我用xmlhttprequset使用了一下ajax,在ie下行,在firefox下不行。谁能给一个ajax的js的轻便好用的包,在.net和jsp中都能方便用。
test.aspx
<script language=javascript>
function callxmlhttp()
{
var strurl;
var result;
strurl = "a.aspx?strID=100";
var xmlhttp;
try{
xmlhttp=new XMLHttpRequest();
}catch(e){
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("get", strurl, false);
xmlhttp.send();
result = xmlhttp.ResponseText;
document.getElementById("Text1").value=result;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Button1" type="button" value="ajax调用" onclick="callxmlhttp()" />
<textarea id="Text1" style="width: 544px; height: 418px"></textarea></div>
</form>
</body>
</html>
a.aspx:protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString.Keys.Count > 0 && Request.QueryString["strID"].Length > 0)
{
Response.Clear();
string strID = Request.QueryString["strID"].ToString();
Response.Write("要返回的值"+strID);
Response.End(); }
}
以上代码在ie中没问题,在firefox中不行,不知适应多个浏览器的代码如何写,网上找了都不大对。
所以谁能提供一个好用的js包,能在.net和jsp中用就好了,免费重复学习。
test.aspx
<script language=javascript>
function callxmlhttp()
{
var strurl;
var result;
strurl = "a.aspx?strID=100";
var xmlhttp;
try{
xmlhttp=new XMLHttpRequest();
}catch(e){
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("get", strurl, false);
xmlhttp.send();
result = xmlhttp.ResponseText;
document.getElementById("Text1").value=result;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Button1" type="button" value="ajax调用" onclick="callxmlhttp()" />
<textarea id="Text1" style="width: 544px; height: 418px"></textarea></div>
</form>
</body>
</html>
a.aspx:protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString.Keys.Count > 0 && Request.QueryString["strID"].Length > 0)
{
Response.Clear();
string strID = Request.QueryString["strID"].ToString();
Response.Write("要返回的值"+strID);
Response.End(); }
}
以上代码在ie中没问题,在firefox中不行,不知适应多个浏览器的代码如何写,网上找了都不大对。
所以谁能提供一个好用的js包,能在.net和jsp中用就好了,免费重复学习。
解决方案 »
- 关于手机短信提示的实现??该怎么搞。?
- 请问GridView里 与DataSourceID相同的DataSource 还有session问题
- 高歌版主 请进 大家也都进来顶一下
- 字符串
- 请问怎么对datalist控件中的某个控件进行操作
- 关于接口
- 特着急,高手帮忙!如何在DataGrid中動態創建CheckBoxList(數據庫中加載數據)並記錄它的選中狀態,最好有完整例子,150分相送
- asp.net 图片不存在时显示一个默认的图片?(不是说在每个图片里加判断)
- 想转行的兄弟们进来看看啊~~~!!!
- 大家帮帮忙,看个问题
- 客户端程序,如何通过脚本js来读取和写入服务器上的文本123.txt?
- 我的asp.net困惑大全,望大家指点!感谢!
req = new XMLHttpRequest();
req.onreadystatechange = callback;
req.open("GET", url, true);
req.send(null);
} // branch for IE/Windows ActiveX version
else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = callback;
req.open("GET", url, true);
req.send();
}
}
xmlhttp.send();
result = xmlhttp.ResponseText;
document.getElementById("Text1").value=result; --------------------------------谁教你这样写程序的?
google的gwt都是很好用的跨浏览器的哟