mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath("../../codebase/imgs/");
mygrid.setHeader("Name,Date of Birth, First Book Published");
mygrid.setInitWidths("*,100,100");
mygrid.setColAlign("left,center,center");
mygrid.setColTypes("ed,dhxCalendar,dhxCalendarA");
mygrid.setColSorting("str,date,date");
mygrid.setSkin("dhx_skyblue");
mygrid.init();
mygrid.loadXML("../common/grid_dates.xml");这是dhtmlx js库中的gird,它的loadXML能加载本地xml,也能加载服务器端的xml;JS怎么加载本地xml的?它这个加载服务器xml是通过发ajax请求吗,还是别的?

解决方案 »

  1.   

    应该是用script跨域获取数据
    你看下源代码不就得了
      

  2.   

    他的JS库在你手上 你看下 源代码怎么实现的loadXML就搜索这个
      

  3.   


    /**
      *     @desc: load XML
      *     @type: private
      *     @param: filePath - xml file path
      *     @param: postMode - send POST request
      *     @param: postVars - list of vars for post request
      *     @topic: 0
      */
    dtmlXMLLoaderObject.prototype.loadXML=function(filePath, postMode, postVars, rpc){
    if (this.rSeed)
    filePath+=((filePath.indexOf("?") != -1) ? "&" : "?")+"a_dhx_rSeed="+(new Date()).valueOf();
    this.filePath=filePath; if ((!_isIE)&&(window.XMLHttpRequest))
    this.xmlDoc=new XMLHttpRequest();
    else {
    if (document.implementation&&document.implementation.createDocument){
    this.xmlDoc=document.implementation.createDocument("", "", null);
    this.xmlDoc.onload=new this.waitLoadFunction(this);
    this.xmlDoc.load(filePath);
    return;
    } else
    this.xmlDoc=new ActiveXObject("Microsoft.XMLHTTP");
    } if (this.async)
    this.xmlDoc.onreadystatechange=new this.waitLoadFunction(this);
    this.xmlDoc.open(postMode ? "POST" : "GET", filePath, this.async); if (rpc){
    this.xmlDoc.setRequestHeader("User-Agent", "dhtmlxRPC v0.1 ("+navigator.userAgent+")");
    this.xmlDoc.setRequestHeader("Content-type", "text/xml");
    } else if (postMode)
    this.xmlDoc.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');

    this.xmlDoc.setRequestHeader("X-Requested-With","XMLHttpRequest");
    this.xmlDoc.send(null||postVars); if (!this.async)
    (new this.waitLoadFunction(this))();
    };
      

  4.   


    兄弟,你这代码能否解释下的。
    我只能理解向服务器发个ajax请求。