网络编程
位置:首页>> 网络编程>> JavaScript>> Ajax改造:使用Ajax和jQuery改进现有站点(4)

Ajax改造:使用Ajax和jQuery改进现有站点(4)

 来源:PHP100 发布时间:2010-04-02 12:50:00 

标签:ajax,jquery,web标准,用户体验

代码

Customize Me Now 的功能演示代码只提供了客户端部分:HTML CSS、JavaScript 代码和图像文件。在实际中,您显然还需要一个大型的服务器端组件:Microsoft® ASP.NET、Java 技术、Ruby on Rails、Django 或 PHP。但是 jQuery 的美妙之处在于,它纯粹关于客户端。您可以使用 Ajax 简化您的用户体验,无需服务器端组件。我没有提供任何服务器端代码,因为这些细节对于这个项目无关紧要。您只需知道当您打开一个 HTML 文件时,就会有一个 PHP 模板、一个 JavaServer Pages™ (JSP) 文件或任何其他将 HTML 发送到服务器的文件。

下载了 1.0 版应用程序的源代码之后,请看一下其中一个页面的标记。它应该与清单 1 类似。

清单 1. results.html 1.0 的 HTML 代码

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"& 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
<title>Customize Me Now: Search Results</title> 
<link rel="stylesheet" type="text/css" href="../css/customizemenow.css"/> 
</head> 
<body id="CMN"> 
<!--[header goes here]--> 
<div id="main"> 
<form method="GET" action="comparison.html"> 
<h1>Search Results</h1> 
<div class="buttons"> 
<input class="button" type="submit" name="submitTop" id="submitTop" 
value="Compare Selected Products" /> 
or <a href="index.html">search again</a> 
</div> 
<table class="searchResults"> 
<thead> 
<tr> 
<th>Product</th> 
<th>Description</th> 
<th>Options</th> 
<th>Compare</th> 
<th>Actions</th> 
</tr> 
</thead> 
<tr> 
<td class="name"> 
<a target="productPopup" 
href="productPopup.html?product=A">Pizza</a> 
</td> 
<td class="desc"> 
A delicious Italian treat.<br /> 
[<a href="detail.html?product=A">full product details</a>] 
</td> 
<td class="options"> 
<ul> 
<li> 
<a target="optionsPopup" 
href="optionsPopup.html?product=A">crust</a> 
</li> 
<li> 
<a target="optionsPopup" 
href="optionsPopup.html?product=A">cheese</a> 
</li> 
<li> 
<a target="optionsPopup" 
href="optionsPopup.html?product=A">toppings</a> 
</li> 
</ul> 
</td> 
<td class="action"> 
<input type="checkbox" target="productPopup" name="compareA" 
id="compareA" value="true" checked="checked"/> 
</td> 
<td class="action"> 
<a class="button" href="customize.html?product=A">customize 
product</a> 
<a class="button" href="cart.html?product=A">add to cart with 
default options</a> 
</td> 
</tr> 
<!--[additional table rows go here]--> 
</table> 
<div> 
<div class="buttons"> 
<input class="button" type="submit" name="submitBottom" id="submitBottom" 
value="Compare Selected Products" /> 
or <a href="index.html">search again</a> 
</div> 
</form> 
</div> 
<!--[footer goes here]--> 
</body> 
</html> 

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com