小弟在此先说声谢谢呀?
代码如下:
var xmlHttp = false;
try
{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e2)
{
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined')
{
xmlHttp = new XMLHttpRequest();
}
function callServer()
{
var url = "PageName.aspx?Id=" + escape("zx"); xmlHttp.open("POST", url, true);
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
}
function updatePage()
{
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
// test1.innerHTML=response;
//alert(response);
document.getElementById('test1').innerHTML=response;
}
} 最后在:
<div><span style="padding:0 2px 0 2px; font-size:10pt; font-weight:bolder;" id="test1" div>里显示不出来?
代码如下:
var xmlHttp = false;
try
{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e2)
{
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined')
{
xmlHttp = new XMLHttpRequest();
}
function callServer()
{
var url = "PageName.aspx?Id=" + escape("zx"); xmlHttp.open("POST", url, true);
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
}
function updatePage()
{
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
// test1.innerHTML=response;
//alert(response);
document.getElementById('test1').innerHTML=response;
}
} 最后在:
<div><span style="padding:0 2px 0 2px; font-size:10pt; font-weight:bolder;" id="test1" div>里显示不出来?
解决方案 »
- 给js 中对象传值不成功!
- IE和Firefox兼容情况下怎样在子Iframe内调用父窗口的变量和函数?
- javascript怎么刷新父窗口的父窗口啊
- 奇怪的问题
- 表单验证的问题,请高手帮忙解决!急!急! 急!
- 求动态表格生成代码(在线)
- 如何让弹出菜单显示在主页最上层
- 加了javascript代码以后,网页就显示不出来了
- 怎样得到ActiveX控件的值?
- 我的<div>中有一段html内容,现在想将其中被<b></b>加粗的所有内容去除掉,除了字符串操作,是不是还有更方便的办法?
- 输出prototype原型里的值
- Ext.data.Record的create方法里的元素在api的什么地方可以找得到
ps:建议这个xmlHttp = new XMLHttpRequest(); 写到最前面
if(xmlHttp.status==200) {
var response = xmlHttp.responseText;
// test1.innerHTML=response;
//alert(response);
document.getElementById('test1').innerHTML=response;
}
}
可是改成你说的那样在firefox里还是没有效果?
xhr.onreadystatechange=handler;
xhr.open('POST',url,true);
xhr.setRequestHeader('Content-Length',args.data.length);//post提交是要加这两行,好像上面这一行可以省略,
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xhr.send("Id=" + escape("zx"); );//post提交时参数要放在这里
//根据window.XMLHttpRequest对象是否存在使用不同的创建方式
if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest(); //FireFox、Opera等浏览器支持的创建方式
} else {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");//IE浏览器支持的创建方式
}
}
代码如下:
var xmlHttp = false;
if (!xmlHttp && typeof XMLHttpRequest != 'undefined')
{
xmlHttp = new XMLHttpRequest();
}
try
{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e2)
{
xmlHttp = false;
}
}
function callServer()
{
var url = "PageName.aspx?Id=" + escape("zx");
// xmlHttp.open("POST", url, true);
// xmlHttp.onreadystatechange = updatePage;
// xmlHttp.send(null);
xmlHttp.onreadystatechange=updatePage;
xmlHttp.open('POST',url,true);
// xmlHttp.setRequestHeader('Content-Length',args.data.length);//post提交是要加这两行,好像上面这一行可以省略,
xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xmlHttp.send("Id=" + escape("zx"));//post提交时参数要放在这里 }
function updatePage()
{
if (xmlHttp.readyState == 4) {
if(xmlHttp.status==200) { var response = xmlHttp.responseText;
// test1.innerHTML=response;
//alert(response);
document.getElementById('test1').innerHTML=response;
}
}
} 而且还把utf-8格式加了?
在firefox好像根本取不到数据?在IE可以