html
*/
<p>{:L('language')}
<select name="language" id="language" onchange="Changelang();">
<option value="1">English</option>
<option value="2">中文版</option>
</select>
</p>/*Jquery
*/
<script type="text/javascript">
var path=window.location.hostname;
function Changelang(){
if($('#language').find("option:selected").attr("value")=='1'){
jQuery.ajax({
type : 'POST',
cache : false,
contentType : "application/x-www-form-urlencoded",
url : "http://"+path+'/xygc/index.php/home/index/langeage?L=en',
dataType : 'json',
success : function(data) {
}
})
}else{
jQuery.ajax({
type : 'POST',
cache : false,
contentType : "application/x-www-form-urlencoded",
url : "http://"+path+'/xygc/index.php/home/index/langeage?L=cn',
dataType : 'json',
success : function(data) {
}
})
}
}/*thinkphp*/ //语言设置
public function langeage() {
$lang=$_GET['L'];
cookie('think_language',$lang);
} 最佳答案