asfman
android developer
posts - 90,  comments - 213,  trackbacks - 0

var FCKXml = function()
{}
function escapeHTML(text) {
text=text.replace('\n','');
text=text.replace('&','&');
text=text.replace('<','&lt;');
text=text.replace('>','&gt;');
return text;
}

FCKXml.prototype.GetHttpRequest = function()
{
if ( window.XMLHttpRequest )// Gecko
return new XMLHttpRequest() ;
else if ( window.ActiveXObject )// IE
return new ActiveXObject("MsXml2.XmlHttp") ;
}

FCKXml.prototype.PostUrl = function( urlToCall, postString , asyncFunctionPointer,funcParam )
{
var oFCKXml = this ;
var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ;
var oXmlHttp = this.GetHttpRequest() ;
oXmlHttp.open( "POST", urlToCall, bAsync ) ;
if ( bAsync )
{
oXmlHttp.onreadystatechange = function()
{
if ( oXmlHttp.readyState == 4 )
{
result = oXmlHttp.responseText; //你可以自行换成oXmlHttp.responseXML,那么就是xml对象了。
oFCKXml.DOMDocument = oXmlHttp.responseXML ;
//alert(result);
asyncFunctionPointer( result,funcParam ) ;
}
}
}
if (this.debug==1)alert(postString);
oXmlHttp.setRequestHeader(  "CONTENT-TYPE","application/x-www-form-urlencoded");
oXmlHttp.send( postString ) ;

if ( ! bAsync )
this.DOMDocument = oXmlHttp.responseXML ;
}

FCKXml.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer,funcParam )
{
var oFCKXml = this ;
var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ;
var oXmlHttp = this.GetHttpRequest() ;
oXmlHttp.open( "GET", urlToCall, bAsync ) ;
if ( bAsync )
{
oXmlHttp.onreadystatechange = function()
{
if ( oXmlHttp.readyState == 4 )
{
result = oXmlHttp.responseText; //你可以自行换成oXmlHttp.responseXML,那么就是xml对象了。
oFCKXml.DOMDocument = oXmlHttp.responseXML ;
//alert(oXmlHttp.responseXML.documentElement.xml);
asyncFunctionPointer( result,funcParam ) ;
}
}
}

oXmlHttp.send( null ) ;

if ( ! bAsync )
this.DOMDocument = oXmlHttp.responseXML ;
}

FCKXml.prototype.SelectNodes = function( xpath )
{
if ( document.all )// IE
return this.DOMDocument.selectNodes( xpath ) ;
else// Gecko
{
var aNodeArray = new Array();

var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument,
this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ;
if ( xPathResult )
{
var oNode = xPathResult.iterateNext() ;
 while( oNode )
 {
 aNodeArray[aNodeArray.length] = oNode ;
 oNode = xPathResult.iterateNext();
 }
}
return aNodeArray ;
}
}

FCKXml.prototype.SelectSingleNode = function( xpath )
{
//alert( xpath + '=--' + this.DOMDocument.selectSingleNode( xpath ) +this.DOMDocument );
if ( document.all )// IE
return this.DOMDocument.selectSingleNode( xpath ) ;
else// Gecko
{
var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument,
this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), 9, null);

if ( xPathResult && xPathResult.singleNodeValue )
return xPathResult.singleNodeValue ;
else
return null ;
}
}

/* 将表单的数据连结起来。 */
function joinForm(form){
postStr = '';
for (i=0;i<form.length ;i++ )
postStr +=form[i].name+"="+form[i].value+"&";
postStr = postStr.substr(0,(postStr.length-1));
return postStr;
}//end func

posted on 2006-04-03 14:24 汪杰 阅读(241) 评论(0)  编辑 收藏 引用 所属分类: hengxing网站js
只有注册用户登录后才能发表评论。

<2024年5月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用链接

留言簿(15)

随笔分类(1)

随笔档案(90)

文章分类(727)

文章档案(712)

相册

收藏夹

http://blog.csdn.net/prodigynonsense

友情链接

最新随笔

搜索

  •  

积分与排名

  • 积分 - 459277
  • 排名 - 6

最新随笔

最新评论

阅读排行榜

评论排行榜