一个关于ajax的例子(prototype)
关键字: prototype自己做了一个关于ajax的例子,希望能给你带来方便,谢谢!!!
所用的JS框架是prototype-1.6.0.2.js当前最新版。
demo.js-------------
//demo
var Demo=Class.create();
Demo.prototype={
//init
initialize:function(){
this.author="ddh";
this.url="handle.jsp";
this.pars="";
},
//submit
submitData:function(title,content,divName){
this.pars="title="+title+"&content="+content;
new Ajax.Updater(
divName,
this.url,
{
method: 'get',
parameters: this.pars
});
}
}
handle.js-------------
//handle
function _submitData()
{
demo=new Demo();
demo.submitData($F('title'),$F('content'),'result');
}
index.jsp---------------
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>insert news</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript" src="js/prototype-1.6.0.2.js"></script>
<script type="text/javascript" src="js/demo.js"></script>
<script type="text/javascript" src="js/handle.js"></script>
</head>
<body>
Insert News <br> <br>
Title: <input id="title" name="title"><br/>
Content:<textarea id="content" name="content" rows="5" cols="17"></textarea>
<br/><br/>
<input type="button" onclick="_submitData();" value="submit">
<br/><br/><br/>
<div id="result"></div>
</body>
</html>
其详细资料请查看附件。
- 10:04
- 浏览 (510)
- 评论 (1)
- 分类: JS(javaScript)
- 进入论坛
- 发布在 代码生成器 圈子
- 相关推荐
发表评论
提醒: 该博客已发表在公共论坛,博客所有留言会成为论坛回贴,留言请注意遵守论坛发贴规则
- 浏览: 26623 次
- 性别:

- 来自: 广州

- 详细资料
搜索本博客
我的相册
共 8 张
最近加入圈子
链接
最新评论
-
一个jfreechart的例子
kan kan 我的项目正需要
-- by discovery12 -
真正的用window.open()代 ...
今天也在搞这问题,最后还是放弃open() "兼容FF,IE等多种浏览器" 你不 ...
-- by icefire -
DWR又一例级联(省份-城 ...
我想问下,为什么不用dwr中util.js的方法来生成呢?不是更好用点吗,而且代 ...
-- by hxdream -
一个关于ajax的例子(proto ...
hehe谢了
-- by shiren1118 -
一个关于DWR的例子
Run 写道 <script type='text/javascript ...
-- by sway






评论排行榜