js脚本代码如下
function updatehits(id){
insid=id;
http= getXMLHTTPRequest();
var reurl=window.location.pathname;
string=reurl.substring(reurl.lastIndexOf('/')+1,reurl.length);
if(reurl.substring(0, 3)=="data"){
alert(string);
string =reurl.substring(0, 3);
}
var url="updatehits?id="+insid+"&o="+string+"";
if(http){ // 成功创建XMLHTTPRequest对象
http.open("POST",url,true); // 与服务端建立连接(请求方式post或get,地址,true表示异步)
http.onreadystatechange=callback; // 指定回调函数
http.send(null); // 发送请求
}
}
// 创建XMLHTTPRequest对象
function getXMLHTTPRequest(){
var xmlHttp;
if(window.XMLHttpRequest){
xmlHttp=new XMLHttpRequest(); // 非IE浏览器,用xmlhttprequest对象创建
}else if(window.ActiveXObject){
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); // IE浏览器用activexobject对象创建
}
return xmlHttp;
}
function callback(){
if(http.readyState==4){
if(http.status==200){
processResponse();
}
}
}
// 处理服务器端响应
function processResponse(){
var text=http.responseText;
var bool=text.substring(0,4);
var u=text.substring(4,text.length); if(bool=="true"){
if(u=="institutionsResume.jsp"){
parent.window.location.href="jgnew.jsp?insid="+insid;
}
if(u=="res.jsp"){
parent.window.location.href="teacher.jsp?userid="+insid;
}
}else{
}
}
IE6 和FF 都可以正常运行,到ie8那就不行,提示说拒绝访问
指定代码段:http.open("POST",url,true);别说我没baidu过,搜了好久也没看到这样的问题过。
哪位大侠帮我看看,急阿~~~~~~~在线等。
function updatehits(id){
insid=id;
http= getXMLHTTPRequest();
var reurl=window.location.pathname;
string=reurl.substring(reurl.lastIndexOf('/')+1,reurl.length);
if(reurl.substring(0, 3)=="data"){
alert(string);
string =reurl.substring(0, 3);
}
var url="updatehits?id="+insid+"&o="+string+"";
if(http){ // 成功创建XMLHTTPRequest对象
http.open("POST",url,true); // 与服务端建立连接(请求方式post或get,地址,true表示异步)
http.onreadystatechange=callback; // 指定回调函数
http.send(null); // 发送请求
}
}
// 创建XMLHTTPRequest对象
function getXMLHTTPRequest(){
var xmlHttp;
if(window.XMLHttpRequest){
xmlHttp=new XMLHttpRequest(); // 非IE浏览器,用xmlhttprequest对象创建
}else if(window.ActiveXObject){
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); // IE浏览器用activexobject对象创建
}
return xmlHttp;
}
function callback(){
if(http.readyState==4){
if(http.status==200){
processResponse();
}
}
}
// 处理服务器端响应
function processResponse(){
var text=http.responseText;
var bool=text.substring(0,4);
var u=text.substring(4,text.length); if(bool=="true"){
if(u=="institutionsResume.jsp"){
parent.window.location.href="jgnew.jsp?insid="+insid;
}
if(u=="res.jsp"){
parent.window.location.href="teacher.jsp?userid="+insid;
}
}else{
}
}
IE6 和FF 都可以正常运行,到ie8那就不行,提示说拒绝访问
指定代码段:http.open("POST",url,true);别说我没baidu过,搜了好久也没看到这样的问题过。
哪位大侠帮我看看,急阿~~~~~~~在线等。
坐等高人
能不能把JSP代码和servlet代码都发过来,让我也试试呀,我的也是IE8
你换成jquery试试吧
主要是我不会jquery 不然那用这么苦命阿。
原因我知道了,需要的朋友再call我好了,呵呵。
<title>test1</title>
<script type="text/javascript">
function loadXMLDoc()
{
var xmlhttp;
if(window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=Function()
{
if(xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("MyDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","test1.txt",true);
xmlhttp.send();
}
</script>
<body>
<div id="MyDiv">
Let Ajax change this text!
<button type="button" onclick="loadXMLDoc()">通过Ajax改变文字内容</button>
</div>
</body>
</html>
只能给相对路径../方法。
只能给相对路径../方法。
//这里只能这样。
//不能
var url="http://127.0.0.1:8080/Text/updatehits?id="+insid+"&o="+string+"";
//否则IE8 不认的
唉,还是自己可靠,结贴了。
原因我知道了,需要的朋友再call我好了,呵呵。
可以帮我解决下问题吗?QQ:825145840 感谢!