现在我按照fason说的XMLHttpRequest来做 出现一个错误:Mothod not allowed,可能是我写错了,把代码添出来: var req function p1s(){ var data,url url=document.location.href data=iView.document.body.innerHTML if (window.XMLHttpRequest) { req = new XMLHttpRequest() req.open('get', url, true) req.onreadystatechange = processReqChange req.send(data) } else if (window.ActiveXObject) { req = new ActiveXObject('Microsoft.XMLHTTP') if (req) { req.open('get', url, true) req.onreadystatechange = processReqChange req.send(data); } } }function processReqChange() { if (req.readyState == 4) { if (req.status == 200) { alert(req.responseText) } else { alert("There was a problem retrieving the XML data:\n" + req.statusText) } } } 不知道哪里错了,各位大虾帮忙看看,谢谢!
这个问题已经解决: 把req = new ActiveXObject('Microsoft.XMLHTTP') 改为req = new ActiveXObject('Msxml2.XMLHTTP')就可以了 但是不知道为什么?哪个大哥知道的话麻烦解释一下(我自己猜测是不是跟xml的版本有关?)
-----------------------------
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META Http-Equiv="Content-Type" Content="text/html; charset=gb2312">
<SCRIPT LANGUAGE="JavaScript">
<!--
function GetMonth(){
//创建对象
data = new ActiveXObject("msxml");
//传人GetMonth.asp中以XML的方式返回。
data.URL = "传人GetMonth.asp?t1="+document.all.t1.value+"&t2="+document.all.t2.value;
//将selectAccessoryType.asp中信息赋值给当前页面的变量。
if (data.root.children != null)
{
var DiffMonth=data.root.children.item(0).text;
}
alert(DiffMonth);
}
//-->
</SCRIPT>
</HEAD><BODY>
<FORM METHOD=POST ACTION="">
<INPUT TYPE="text" NAME="t1" value="2005-1-1"><BR>
<INPUT TYPE="text" NAME="t2" value="2005-2-1"><BR>
<INPUT TYPE="button" value="ok" onclick="GetMonth()"></FORM>
</BODY>
</HTML>GetMonth.asp
----------------------------------
<%@ Language=VBScript %>
<%
Dim t1,t2
t1=Request.QueryString("t1")
t2=Request.QueryString("t2")
Dim strPsn
strPsn="<item>"strPsn=strPsn&"<DateDiff>"&DateDiff("m",t1,t2)&"</DateDiff>"strPsn=strPsn&"</item>"
%>
<?xml version="1.0" encoding="gb_2312-80"?>
<%=strPsn%>
但是 friendlyFour(web开发四人组) 提供的好像不是我要的
fason(咖啡人生) 这位大虾能否说的详细些?
我现在是在iframe做修改,就是在iframe里修改完后把数据保存到数据库中!页面没有post
出现一个错误:Mothod not allowed,可能是我写错了,把代码添出来:
var req
function p1s(){
var data,url
url=document.location.href
data=iView.document.body.innerHTML
if (window.XMLHttpRequest) {
req = new XMLHttpRequest()
req.open('get', url, true)
req.onreadystatechange = processReqChange
req.send(data)
}
else if (window.ActiveXObject) {
req = new ActiveXObject('Microsoft.XMLHTTP')
if (req) {
req.open('get', url, true)
req.onreadystatechange = processReqChange
req.send(data);
}
}
}function processReqChange()
{
if (req.readyState == 4) {
if (req.status == 200) {
alert(req.responseText)
}
else {
alert("There was a problem retrieving the XML data:\n" + req.statusText)
}
}
}
不知道哪里错了,各位大虾帮忙看看,谢谢!
把req = new ActiveXObject('Microsoft.XMLHTTP')
改为req = new ActiveXObject('Msxml2.XMLHTTP')就可以了
但是不知道为什么?哪个大哥知道的话麻烦解释一下(我自己猜测是不是跟xml的版本有关?)
这个是msdn的写法,你自己看了main();function main()
{
try {
var xhr = new ActiveXObject("MSXML2.XMLHTTP.3.0");
xhr.open("GET",
"http://localhost/sxh/contact.asp?SearchID=John Doe",
false);
xhr.send(); var doc = xhr.responseXML;
alert(doc.xml);
}
catch (e) {
alert(e.description);
}
}function alert(s)
{
WScript.Echo(s);
}
var h=null;
var p=["MSXML4","MSXML3","MSXML2","MSXML","Microsoft"];
if(window.XMLHttpRequest)return new XMLHttpRequest();
for(var i=0;i<p.length;i++){
try{
h=new ActiveXObject(p[i]+".XMLHTTP");
return h;
}catch(e){}
}
return h;
}var xmlhttp = getXmlHttp();
我在网上找到一个dome,这个demo的实现的效果跟我想实现的基本一样
但是看了它的原码,有些没有看懂,网址是:http://demo.wikiwyg.net/wikiwyg/demo/
我要实现这个效果,代码该怎么写呢?
iframe内的内容改变,点击save后,怎么传给页面的?
先谢谢各位了,分不够可以另外开贴!