Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/422.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用ajax cakephp将视图加载到布局时url不更改?_Javascript_Php_Ajax_Jquery_Cakephp - Fatal编程技术网

Javascript 使用ajax cakephp将视图加载到布局时url不更改?

Javascript 使用ajax cakephp将视图加载到布局时url不更改?,javascript,php,ajax,jquery,cakephp,Javascript,Php,Ajax,Jquery,Cakephp,我正在使用此函数将视图加载到默认布局 function viewContent(url){        $.ajax({              type: "post",  // Request method: post, get              url: url, // URL to request              success: function(response) {                                   document.get

我正在使用此函数将视图加载到默认布局

 function viewContent(url){
       $.ajax({
             type: "post",  // Request method: post, get
             url: url, // URL to request
             success: function(response) {
                                  document.getElementById("content").innerHTML = response;
                           },
                           error:function (XMLHttpRequest, textStatus, errorThrown) {
                                  alert(textStatus);
                           }
          });
          return false;
}

  • 我从解析适当url的链接调用该函数。但当我点击这些链接时,视图加载没有任何问题,但浏览器URL没有改变

    一般来说,URL不会在ajax请求中被修改

    下面的帖子讨论一个方法

    你也可以对下面的内容感兴趣


    您两天前问了一个问题
    http://stackoverflow.com/questions/20836660/render-views-to-the-layout-without-refreshing-the-page-cakephp/20837687#20837687

    现在这个

    更好的解决你的问题的方法是

    <li><?=$html->link(__('Users',true),'javascript:viewContent("view_users/")');?></li>
    

    最后一件事是立刻问你的问题,这样你就能得到更好的答案

    我要做的是保持页眉和页脚静态,并加载其他视图而不刷新此网站的页面。我要做的是保持页眉和页脚静态,并加载其他视图而不刷新此网站的页面。页眉和页脚缓存的使用方法可能重复,页眉和页脚在默认布局中。请告诉我有关页眉和页脚文件的更多信息,例如您是如何创建它们的,例如您正在使用一些繁重的查询来创建它们,或者它们只是html文件?如果可能的话,说明你的全部问题。
    Step 1: use caching for header & footer. 
    Step 2: Do not use ajax to update view content.
    Step 3: Use standard redirection for pages in order to maintain your links.
    
    Note: use KISS(Keep it simple stupid) methodology