请问大家,能否帮我把下面这段js代码,用extjs的方式写出来,要求是点击3个button,分别是中国国旗,法国国旗,美国国旗,传输3种不同的语言。代码如下:
$(document).ready(function(){
$("#ch").click(function(){
$.ajax({
url:"setLanguage.do",
data: "language=zh",
success:function(result){
location.reload();
}});
});
$("#ck").click(function(){
$.ajax({
url:"setLanguage.do",
data: "language=en",
success:function(result){
location.reload();
}});
});
});
我编写了一下,但是,在我的extjs前端+ssh的后台源程序里,怎么也不实现全部的语言转换。我很纳闷,请高手指点。
我编写的extjs代码
items:[{
xtype: 'button',
html: '<img id="zh" src="./img/chinese flag_sm.png" alt="Chinese"/></a>',
width: 32,
style: 'margin-left: 10px;',
//tips: 'Language',
handler:// $(document).ready(function(){
//window.onload=function(){document.getElementById('#zh').onclick=function(){
function(){
$.ajax({
url:"com.hrmsys.action.Change",
data: "language=zh",
success:function(result){
location.reload();
}}
)}
},{
xtype:'button',
html: '<img id="en" src="./img/british flag_sm.png" alt="Chinese"/></a>',
width:32,
style:'margin-left:10px;',
tips: "Language",
handler:
//window.onload=function(){document.getElementById('#en').onclick=function(){
function(){
$.ajax({
url:"Change.do",
data: "language=zh",
success:function(result){
location.reload();
}}
)}
},{
xtype:'button',
html: '<img id="fr" src="./img/france flag_sm.png" alt="Chinese"/></a>',
width:32,
style: 'margin-left:10px;',
tips: "Language",
handler:
//window.onload=function(){
//document.getElementById('#fr').onclick=function(){
function(){
$.ajax({
url:"Change.do",
data: "language=zh",
success:function(result){
location.reload();
}}
)}
}]
你用的还是jquery的代码,jQuery框架导入没有?没有肯定报错了,extjs就有ajax支持,不行也要用jQuery了
你的ajax执行了什么操作?不会就是单单服务器设置个cookie而已吧?设置cookie js就行了,不需要经过服务器。。。切换语言这种一般cookie就行了,服务器端获取cookie存储的语言进行不同语言设置
http://docs.sencha.com/extjs/4.1.3/#!/api/Ext.Ajax-method-request