AJax技术

JSP教程,Java技巧及代码-虚拟主机资讯

字号+ 作者:H5之家 来源:H5之家 2015-09-29 17:17 我要评论( )

AJaX for weblogs-JSP教程,Java技巧及代码-西部数码是西部地区最大的虚拟主机、域名注册服务商!20余项虚拟主机领先优势,4000用户的共同选择!领先的虚拟主机技

AJaX for weblogs-JSP教程,Java技巧及代码

作者:网友供稿 点击:9

  西部数码-全国虚拟主机10强!20余项虚拟主机管理功能,全国领先!第6代双线路虚拟主机,南北访问畅通无阻!虚拟主机可在线rar解压,自动数据恢复设置虚拟目录等.虚拟主机免费赠送访问统计,企业邮局.Cn域名注册10元/年,自助建站480元起,免费试用7天,满意再付款!P4主机租用799元/月.月付免压金!

文章页数:[1] 

转: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("")!=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 ‘’ 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.


文章整理:西部数码--专业提供域名注册、虚拟主机服务

以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

相关主题

文章页数:[1] 

热门文章

·IReport与JasperReport开发详解一-JSP教程,Java技巧及代码
·JSTL(JSP标准标签库)介绍-JSP教程,资料/其它
·格式化输入日期时间控件 JieFormattedDateBox-JSP教程,Java技巧及代码
·JSTL简化JSP编码-JSP教程,Jsp/Servlet
·JUnit和单元测试入门简介-JSP教程,Java技巧及代码
·从数据库中读取一个图片并保存为一个图片文件-JSP教程,数据库相关
·Java Swing入门基础-JSP教程,Java技巧及代码
·IntelliJ IDEA培训-JSP教程,Java技巧及代码
·通过JSP的预编译消除性能瓶颈-JSP教程,Jsp/Servlet
·Java中利用JMF编写摄像头拍照程序-JSP教程,Java技巧及代码


最新文章

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
网友点评
<