初学Ext,刚刚用Ext做了个登录界面,其中的验证码刷新出现了问题,试了好久都没好使,后来想起来再jQuery里的ajax方法是异步的,如果每次请求的URL不变的话,就会由缓存来处理请求,所以需要一个时间戳,保证每次请求的URL不同,在这里加了一下时间戳就可以了,我想这里的原理也应该和jQuery的那个是一样的,贴个代码吧//login.js /*! * Ext JS Library 3.3.0 * Copyright(c) 2006-2010 Ext JS, Inc. * [email protected] * http://www.extjs.com/license */ app = {}; Ext.onReady(function(){ Ext.QuickTips.init(); Ext.form.Field.prototype.msgTarget = 'side'; var bd = Ext.getBody(); app.loginFormPanel = new Ext.FormPanel({ labelWidth: 75, // label settings here cascade unless overridden url:'#', frame:true, width: 350, defaults: {width: 230}, defaultType: 'textfield', items: [{ fieldLabel: 'User Name', name: 'user_name', allowBlank:false },{ fieldLabel: 'Password', inputType:'password', name: 'password', allowBlank:false },{ fieldLabel: 'Verification Code', name: 'veri_code', allowBlank:false },{ xtype:'panel', html:'<div style="padding-left:80px" mce_style="padding-left:80px"><a href="#" mce_href="#"><img alt="如果看不清单击图片更换图片。" onclick="javascript:app.changeCode(this)" id="code" height="30" width="72" src="validateCodeServlet" mce_src="validateCodeServlet" border=0></img></a></div>', border:false } ], buttons: [{ text: 'Save' },{ text: 'Cancel' }] }); app.loginWin = new Ext.Window({ width:400, height:200, title:'Login', plain:true, closable:false, resizable:false, layout:'fit', closeAction:'hide', items:[app.loginFormPanel] }); app.loginWin.show(); app.changeCode = function(obj){ var d = new Date(); obj.src = "validateCodeServlet?d=" + d; } });