求一个EXTJS与AJAX的例子 如题邮箱地址为[email protected]最好写一下步骤或者注释 因为本人刚刚接触EXT 懂得不多非常感谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 90后?<html><head> <title>ext JS ajax</title> <link type="text/css" rel="Stylesheet" href="../ext-3.0/resources/css/ext-all.css" /> <style type="text/css"> #panel1 { margin:50px } </style></head><body><div id='panel1'></div><script type="text/javascript" src="../ext-3.0/adapter/ext/ext-base.js"></script><script type="text/javascript" src="../ext-3.0/ext-all.js"></script><script type="text/javascript">Ext.onReady(function(){ Ext.QuickTips.init(); var form1=new Ext.FormPanel({ renderTo:"panel1", width:500, height:300, frame:true, title:"ajax提交", collapsible:true, minButtonWidth:60, labelAlign:"right", defaultType:"textfield", items:[{ fieldLabel:"用户名", id:"txtName", allowBlank:false, blankText:"用户名不能为空!" },{ fieldLabel:"密码", allowBlank:false, blankText:"密码不能为空!" },{ fieldLabel:"备注" }], buttons:[{ text:"提交", handler:function() { if(form1.form.isValid()) { form1.form.submit({ url:"01ajax.ashx", waitMsg:"正在提交....", success:function(from,action) { Ext.Msg.alert(null,"哈哈成功了"+ Ext.encode(action.result.name)); }, failure:function(form,action) { Ext.Msg.alert(null,"发生了错误"); } }); } } },{ text:"重置", handler:function() { form1.form.reset(); } }] });}); </script></body></html><%@ WebHandler Language="C#" Class="_01ajax" %>using System;using System.Web;public class _01ajax : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; string str = "{success:true,name:\"" + context.Request.Form["txtName"] + "\"}"; context.Response.Write(str); } public bool IsReusable { get { return false; } }} 楼上的例子不错 可是俺忘记了写明开发环境了 是sturts2+jsp开发的不知道楼上的有没有这方面相关的例子呢 上面那个例子基本上不用.net不用jsp也一样,只是接受了一个参数,再输出而已, 弱弱的问一句 不需要导入jar包或者其他的了吗 ExtJS里面的ajax封装好了,不需要导入jar包,上面导入了两个js文件和一个样式 表文件 HTML源码<html><head> <title>ext JS ajax</title> <link type="text/css" rel="Stylesheet" href="../ext-3.0/resources/css/ext-all.css" /> <style type="text/css"> #panel1 { margin:50px } </style></head><body><div id='panel1'></div><script type="text/javascript" src="../ext-3.0/adapter/ext/ext-base.js"></script><script type="text/javascript" src="../ext-3.0/ext-all.js"></script><script type="text/javascript">Ext.onReady(function(){ Ext.QuickTips.init(); var form1=new Ext.FormPanel({ renderTo:"panel1", width:500, height:300, frame:true, title:"ajax提交", collapsible:true, minButtonWidth:60, labelAlign:"right", defaultType:"textfield", items:[{ fieldLabel:"用户名", id:"txtName", name:'username', allowBlank:false, blankText:"用户名不能为空!" },{ fieldLabel:"密码", allowBlank:false, blankText:"密码不能为空!", name:'pwdvalue', inputType:'password' },{ fieldLabel:"备注" }], buttons:[{ text:"提交", handler:function(){ if(form1.form.isValid()) { form1.form.submit({ url:"tijiao.jsp", waitMsg:"正在提交....", success:function(from,action) { Ext.Msg.alert(null,"哈哈成功了"+ Ext.encode(action.result.name)); }, failure:function(form,action) { Ext.Msg.alert(null,"发生了错误"); } }); } } },{ text:"重置", handler:function() { form1.form.reset(); } }] });});</script></body></htmljsp源码<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>tset</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> </head> <body> <% request.setCharacterEncoding("gb2312"); response.setCharacterEncoding("gb2312"); String paramvalue=request.getParameter("username"); String pwdvalue=request.getParameter("pwdvalue"); System.out.println(paramvalue); System.out.println(pwdvalue); if(paramvalue.equals("test")&&pwdvalue.equals("123")){ System.out.println("成功了"); response.getWriter().print("{success:true,name:test}"); } %> </body></html> 今天把代码放到类里面就可以返回了~~~~真的非常的无语啊Ext.onReady(function(){ Ext.QuickTips.init(); var form1=new Ext.FormPanel({ renderTo:"panel1", width:500, height:300, frame:true, title:"ajax提交", collapsible:true, minButtonWidth:60, labelAlign:"right", defaultType:"textfield", url:"test!select.ph", items:[{ fieldLabel:"用户名", id:"txtName", name:'testBean.name', allowBlank:false, blankText:"用户名不能为空!" },{ fieldLabel:"密码", allowBlank:false, blankText:"密码不能为空!", name:'testBean.password', inputType:'password' },{ fieldLabel:"备注" }], buttons:[{ text:"提交", handler:function(){ if(form1.getForm().isValid()) { form1.getForm().submit({ success:function(from,action) { Ext.Msg.alert("返回提示","哈哈成功了"+action.result.msg); }, failure:function(form,action) { Ext.Msg.alert("返回提示","发生了错误"); } }); } } },{ text:"重置", handler:function() { form1.getForm().reset(); } }] });});public String login(){try { request.setCharacterEncoding("utf-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } response.setCharacterEncoding("gb2312"); System.out.println(testBean.getName()); System.out.println(testBean.getPassword()); if(!"".equals(testBean.getName())&&testBean.getPassword()!=null){ if(testBean.getName().equals("test")&&testBean.getPassword().equals("123")){ System.out.println("成功了"); try { response.getWriter().print("{success:true,msg:'test'}"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } return null;}不知道为什么页面提交页面就无法返回了 jQuery.expr[':']和Jquery.cleanData是什么? 求写个图片之间相互切换的js,谢谢啊 js如何判断当前浏览器处于放大或缩小的状态?? 问题很奇怪,关于系统区域时间设置的问题 新手求助、百度文库拖动文字效果的js代码 javascript 脚本出错 能不能在打开网页得时候只下载指定的$(id)里的内容 请教如何触发html中option组件的事件 怎样判断网页是否处于最顶层框架! 如何使用控件数组 同步ajax造成假死 ,怎么处理 js获取XML节点值
<head>
<title>ext JS ajax</title>
<link type="text/css" rel="Stylesheet" href="../ext-3.0/resources/css/ext-all.css" />
<style type="text/css">
#panel1
{
margin:50px
}
</style>
</head>
<body>
<div id='panel1'></div>
<script type="text/javascript" src="../ext-3.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../ext-3.0/ext-all.js"></script><script type="text/javascript">Ext.onReady(function(){
Ext.QuickTips.init();
var form1=new Ext.FormPanel({
renderTo:"panel1",
width:500,
height:300,
frame:true,
title:"ajax提交",
collapsible:true,
minButtonWidth:60,
labelAlign:"right",
defaultType:"textfield",
items:[{
fieldLabel:"用户名",
id:"txtName",
allowBlank:false,
blankText:"用户名不能为空!"
},{
fieldLabel:"密码",
allowBlank:false,
blankText:"密码不能为空!"
},{
fieldLabel:"备注"
}],
buttons:[{
text:"提交",
handler:function() {
if(form1.form.isValid()) {
form1.form.submit({
url:"01ajax.ashx",
waitMsg:"正在提交....",
success:function(from,action) {
Ext.Msg.alert(null,"哈哈成功了"+ Ext.encode(action.result.name));
},
failure:function(form,action) {
Ext.Msg.alert(null,"发生了错误");
}
});
}
}
},{
text:"重置",
handler:function() {
form1.form.reset();
}
}]
});
});
</script>
</body>
</html>
<%@ WebHandler Language="C#" Class="_01ajax" %>using System;
using System.Web;public class _01ajax : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
string str = "{success:true,name:\"" + context.Request.Form["txtName"] + "\"}";
context.Response.Write(str);
}
public bool IsReusable {
get {
return false;
}
}}
是sturts2+jsp开发的
不知道楼上的有没有这方面相关的例子呢
<html>
<head>
<title>ext JS ajax</title>
<link type="text/css" rel="Stylesheet" href="../ext-3.0/resources/css/ext-all.css" />
<style type="text/css">
#panel1
{
margin:50px
}
</style>
</head>
<body>
<div id='panel1'></div>
<script type="text/javascript" src="../ext-3.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../ext-3.0/ext-all.js"></script><script type="text/javascript">Ext.onReady(function(){
Ext.QuickTips.init();
var form1=new Ext.FormPanel({
renderTo:"panel1",
width:500,
height:300,
frame:true,
title:"ajax提交",
collapsible:true,
minButtonWidth:60,
labelAlign:"right",
defaultType:"textfield",
items:[{
fieldLabel:"用户名",
id:"txtName",
name:'username',
allowBlank:false,
blankText:"用户名不能为空!"
},{
fieldLabel:"密码",
allowBlank:false,
blankText:"密码不能为空!",
name:'pwdvalue',
inputType:'password'
},{
fieldLabel:"备注"
}],
buttons:[{
text:"提交",
handler:function(){
if(form1.form.isValid()) {
form1.form.submit({
url:"tijiao.jsp",
waitMsg:"正在提交....",
success:function(from,action) {
Ext.Msg.alert(null,"哈哈成功了"+ Ext.encode(action.result.name));
},
failure:function(form,action) {
Ext.Msg.alert(null,"发生了错误");
}
});
}
}
},{
text:"重置",
handler:function() {
form1.form.reset();
}
}]
});});
</script>
</body>
</html
jsp源码<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>tset</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>
<body>
<%
request.setCharacterEncoding("gb2312");
response.setCharacterEncoding("gb2312");
String paramvalue=request.getParameter("username");
String pwdvalue=request.getParameter("pwdvalue");
System.out.println(paramvalue);
System.out.println(pwdvalue);
if(paramvalue.equals("test")&&pwdvalue.equals("123")){
System.out.println("成功了");
response.getWriter().print("{success:true,name:test}");
}
%>
</body>
</html>
Ext.QuickTips.init();
var form1=new Ext.FormPanel({
renderTo:"panel1",
width:500,
height:300,
frame:true,
title:"ajax提交",
collapsible:true,
minButtonWidth:60,
labelAlign:"right",
defaultType:"textfield",
url:"test!select.ph",
items:[{
fieldLabel:"用户名",
id:"txtName",
name:'testBean.name',
allowBlank:false,
blankText:"用户名不能为空!"
},{
fieldLabel:"密码",
allowBlank:false,
blankText:"密码不能为空!",
name:'testBean.password',
inputType:'password'
},{
fieldLabel:"备注"
}],
buttons:[{
text:"提交",
handler:function(){
if(form1.getForm().isValid()) {
form1.getForm().submit({
success:function(from,action) {
Ext.Msg.alert("返回提示","哈哈成功了"+action.result.msg);
},
failure:function(form,action) {
Ext.Msg.alert("返回提示","发生了错误");
}
});
}
}
},{
text:"重置",
handler:function() {
form1.getForm().reset();
}
}]
});});public String login(){
try {
request.setCharacterEncoding("utf-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
response.setCharacterEncoding("gb2312");
System.out.println(testBean.getName());
System.out.println(testBean.getPassword());
if(!"".equals(testBean.getName())&&testBean.getPassword()!=null){
if(testBean.getName().equals("test")&&testBean.getPassword().equals("123")){
System.out.println("成功了");
try {
response.getWriter().print("{success:true,msg:'test'}");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return null;
}不知道为什么页面提交页面就无法返回了