欢迎光临极品网,更多、更新的资源信息尽在Jpinw.Com!本站所有信息资源每日更新新的内容,请大家继续关注www.Jpinw.com!如果觉得本站还不错,对您有帮助,别忘了向您的朋友推荐本站!请记好本站网址:http://www.Jpinw.com,网站发展靠大家多多的支持!!!

极品网 极品课件 极品论文 极品文学 极品游戏 极品美容 极品手机资源 极品股票

#
免费资源: 免费域名 | 免费空间 | 免费推广 | 免费邮箱 | 免费硬盘 | 免费论坛 | 免费留言 | 免费统计 | 在线投稿 | 更多...
电脑学院: 操作系统 | 安全相关 | 网页设计 | 编程开发 | 建站经验 | 服务器类 | 黑客攻防 | 菜鸟入门 | 教你网赚 | 更多...
文章导航: 网赚学堂 | 网赚秘笈 | 网赚三维 | 网赚先锋 | 网赚资讯 | 感悟网赚 | 众生百态 | 经典美文 | 范文中心 | 更多...
图酷天下: 时事图酷 | 娱乐图酷 | 搞笑图酷 | 时尚图酷 | 体育图酷 | 另类经典 | 论文资源 | 课件下载 | 文学知识 | 更多...

您现在的位置: 极品网 >> 电脑学院 >> 编程开发 >> 编程综合 >> 教程正文

AJaX for weblogs            【字体:
AJaX for weblogs
作者:佚名    教程来源:不详    点击数:    更新时间:2008-1-14    

 








AJaX for weblogs。
  转:Ajax  for  weblogs
The Asynchronous javascript + XML (AJaX) solution is one that can bring happiness and bliss to web designers and web developers alike. However, as with many whiz-bang solutions caution is advised. Google uses it to great effect but personally I think they take it a bit too far. If a page change so much that its context changes then it have switched to a new URI. People often bookmark specific content that’s within a specific context. As soon as this is no longer true it maybe a clue that you’ve gone to far.

The first thing I notice that the solutions is aimed at the heavier web applications. Not surprising. Web applications suffer from constraints that web clients impose on them. This solution gives them a way to check for dynamic content without reloading the current page.

So what does it do? 

Well it’s very simple. It uses javascript to get data from a remote source and then loads that into a specified target. Whatever content you like to wherever you like on the page. Jesse James Garrett of Adaptive Path has written an essay that covers the basics and provides more information on AJaX.

But lets get this sucker running, that’s the fun bit. And it’s pretty easy.

Step 1

Check if your web client can actually handle the http requests. We’ll need to use a Javascipt to do this.
var ajax=false;/*@cc_on @*//*@if (@_jscript_version >= 5) try { ajax = new ActiveXObject("MsXML2.XMLHTTP"); } catch (e) { try { ajax = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { ajax = false; } }@end @*/if (!ajax && typeof XMLHttpRequest!=’undefined’) { ajax = new XMLHttpRequest();}
Step 2

Add the script that will pick up your data. In this case I’m not picking up XML data. But the weblog of your choice and in my case it’s ExpressionEngine will return the xHTML Which in turn will be inserted via the javascript innerHTML methode.
function getMyHTML(serverPage, objID) { if((serverPage.indexOf("http://www.yourdomain.com/")!=0)) return; var obj = document.getElementById(objID); ajax.open("GET", serverPage); ajax.onreadystatechange = function() { if (ajax.readyState == 4 && ajax.status == 200) { obj.innerHTML = ajax.responseText; } } ajax.send(null);}
Step 3

The page that will display the dynamic content will need a placeholder element (tag) with a unique ID. The ID attribute will be used in the second script as a reference point to allow for insertion of the new dynamic content.
<HTML> <head> <title>AJaX test</title> </head> <body onload="getMyHTML(’serverpage.PHP’,’placeholder’)"> <div id="placeholder"> <p>The ‘getMyHTML’ script will overwrite this paragraph.</p> </div> </body></HTML>
This URI in the ‘onload’ is the one which will generate the content.

Step 4

The dynamic bit is parsed by the engine of your choice like; Moveable Type, Expression Engine, word Press etc. Of course you can use any other method of collecting content form a database.

In Expression Engine I’m calling a template that collects the data for my calendar. The whole calendar is outputted as HTML and inserted via the script.

Lets say the URI is ‘http://www.yourdomain.com/tempate/pageid/’ This could in fact be a PHP file or any other serverside script solution. The page only needs to return HTML. Here is an example in PHP.
<?PHP echo '<p>this is a PHP echo text</p>'; ?>
And that’s about it. It’s all pretty old school but there you have it.

 

教程录入:admin    责任编辑:admin 
  • 上一篇教程:

  • 下一篇教程:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关教程
    Java,javascript,JScrip
    javascript和Java区别
    Java技巧(一):会变色的超
    javascript和Java的区别
    javascript调用JAVA
    javascript 和 Java 的区
    JavaServerPages白皮书
    JavaApplet实例:水波
    javascript与JavaApplet
    javascript与Java在浏览
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    极品网
    | 设为首页 | 加入收藏 | 友情链接 | 版权声明 |
    极品网

    Copyright 2006 Jpinw.com 极品网

    备案号:浙ICP备07010375号

    极品网