将所有站点更改为Ajax onload XML

时间:2018-08-12 08:46:06

标签: javascript html mysql ajax xml

我的情况是: 我有一台有限的共享有源服务器。我的旧网站内容很多,正在加载所有访问访问中呈现的php内容时超时。 因此,我试图了解自从第一页和所有其他子页面以来,使用AJAX从xmls文件将所有页面加载到Tableless网站之后,contend的负载如何调整。

例如: 第一页包含许多不同的部分,每个部分的前5条,6条或7条新闻/文章排在最前。

因此,我必须使用AJAX从xml中为首页中每个“框”(div)内容进行加载。

我不了解它如何与onload一起使用,或者在异步加载整个页面之后如何工作,因为我想退出服务器页面脚本,至少是第一页。因此,不适用于每个部分的无表html矩阵,它将从每个部分及其布局获取相关xml的每个内容。 像这样:

第一页:

class FunkyCell: NSButtonCell
{
    ...
    override func drawTitle(_ title: NSAttributedString, withFrame frame: NSRect, in controlView: NSView) -> NSRect {
        return super.drawTitle(title, withFrame: frame.offsetBy(dx: 0, dy: 0), in: controlView)
    }

    func redraw() {
        self.backgroundColor = self.backgroundColor
    }

    override func drawBezel(withFrame frame: NSRect, in controlView: NSView) {
        let path = NSBezierPath(bound: frame.insetBy(dx: 2, dy: 2), withCorners: corners, withRadius: CGFloat(NumKeypadConstants.cornerRadius), flip: flipIt)
        path.lineWidth = NumKeypadConstants.borderWidth
        if(isHighlighted)
        {
            let fillColor: NSColor = NumKeypadConstants.buttonHighlightColor
            let strokeColor: NSColor = NumKeypadConstants.buttonBorderColor
            fillColor.setFill()
            strokeColor.setStroke()
            path.fill()
            path.stroke()
        }
        else
        {
            let fillColor: NSColor = NumKeypadConstants.buttonBackgroundColor
            let strokeColor: NSColor = NumKeypadConstants.buttonBorderColor
            fillColor.setFill()
            strokeColor.setStroke()
            path.fill()
            path.stroke()
        }
    }
}

填充此列/首页的行的来源将是“ news.xml”,“ articles.xml”以及其他不同的部分(共9个部分),每当我包含新的XML文件时,我都会“呈现” xml文件后台文件上的文章(与我今天使用的.RSS文件相同。系统已经在脚本中为每个部分添加了行数/列数,因此首页布局会即时写上,并要求每个部分有多少行并且总是与XML文件中的itens相同(我想知道是否有可能/更好地让这种配置也由Ajax进行(我通常会使用此布局配置呈现另一个xml)。

那将是一个不为首页中的每个访问者消耗更多dadabase咨询的解决方案。

我在这里阅读了很多有关Ajax的内容,但从未找到onload解决方案。总是有一个按钮,是Onchange,onClick的手动请求,但我不知道它如何与直接将其“加载”到DIV一起使用

news.xml,articles.xml等

 <html>
    <head><title>First Page </title></head>
    <body>
    <container>
     <news>
      <new>
       <newstitle><a href="news.php?id=1"> title 1</a></newstitle>
       <newshead> bla bla bla bla bla bla bla bla bla <newshead>
      </new>
      <new>
       <newstitle><a href="news.php?id=2"> title 2</a></newstitle>
       <newshead> bla bla bla bla bla bla bla bla bla <newshead>
      </new>
      <new>
       <newstitle><a href="news.php?id=3"> title 3</a></newstitle>
       <newshead> bla bla bla bla bla bla bla bla bla <newshead>
      </new>
     </news>
     <articles>
      <article>
        <articletitle><a href="content.php?id=3">title 1 </articletile>
        <articledescritption> bla bla bla bla bla bla bla bla bla <newshead>
       </article>
       <artice>
        <articletitle><a href="content.php?id=3">title 1 </articletile>
        <articledescription> bla bla bla bla bla bla bla bla bla <newshead>
       </article>
      </articles>
      .... 
    </container>
    </body>
    </html>

我有什么?脚本的第一部分

  <item>
     <id>xx</id>
     <title>title of content</title>
     <desctiption>bla bla bla bla bla bla</title>
     <category> xx</category>
    </item>

但是我不知道如何获得项目/内容的每个部分,标题,描述的每个div。 谢谢大家。

0 个答案:

没有答案