douqiaotong8682 2012-03-25 14:52
浏览 78
已采纳

如何更改页面语言而不刷新MVC模型?

In the settings.php i have some input for the realname,hobby,city and select tag for the languages

The html form is easy and i'm not going to copy it :)

This is the php code for the form

<?php
if(isset($_POST['submit'])){


  if($this->edit->process()){
    $s = 1; 
  }

}

if($s){echo '<p id="success">Success</p>';}

?>

This is in the view file and when the form is submit the $this->edit = the model for the updating the user data.

Everything work really good but in head.php there is this code

<?php $lang = $this->lange('global',$this->getUser->language($_SESSION['userID']));?>

With him this get the user current language and after that load the file with lange()

So if the submit is like this,the inputs and select tag are changing with what the user have choicen but the to see the new language they have to refresh the page. This is not good,because the user may be confuced that they did something wrong.

But if the form with method="POST" the page is refreshing and still with the old language

  • 写回答

1条回答 默认 最新

  • dongyi6845 2012-03-25 15:15
    关注
    1. It is going to be quite hard to change all the texts in the DOM model to make the language change without redirect. I doubt it's really your desire.
    2. You ought to make a GET method redirect after processing any POST form. So, instead of printing whatever "success" messages you have to reload the page.
    3. Using session to store the language is not good method, the language have to be set by means of the page address - a subdomain (preferable) or a virtual directory.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算