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.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?