Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
litespeed_wiki:cache:litemage:troubleshooting:templates-ajax-based-navigation-error [2016/05/09 20:51]
Long Hu
litespeed_wiki:cache:litemage:troubleshooting:templates-ajax-based-navigation-error [2017/05/09 12:26]
Lisa Clarke
Line 1: Line 1:
-====== Page 2 showing Page 1 content in AJAX Based Navigation ======+~~NOTOC~~ 
 +====== Page 2 showing Page 1 content in AJAX-Based Navigation ======
  
-**Problem**: User using Magento theme that has AJAX based navigation. The site page has two pagesWhen they first click page 2, normal; when they refresh page 2, it shows the cached content of page 1.+====Problem==== 
 +When using Magento theme that has AJAX-based navigation, an incorrect ​page is servedFor example: On a two-page site, when Page is first visitedthe behavior is normal; when Page is refreshed, the cached content of Page is served instead.
  
-**Cause**: This is due to the way the template handles AJAX requests. ​Let'​s ​start from page 1. The current url is "your_site_url.html"By visiting ​this page, the HTML response is cached by LiteMage using it'​s ​URL. Then click on the page 2, which is an AJAX call, the JSON response is also cached by LiteMage using it's URL. Now click the current page(page ​2again, the URL used for requesting the current page is "your_site_url.html#​" and the browser will interpret as "your_site_url.html", so served with the cache page 1.+====Cause==== 
 +This is due to the way the template handles AJAX requests. ​Using our earlier example: let'​s ​say the Page URL is ''​your_site_url.html''​When we visit this page, the HTML response is cached by LiteMage using that URL. When we click on Page 2, which is an AJAX call, the JSON response is also cached by LiteMage using it's URL. When we visit Page 2 again, the URL''​your_site_url.html#​''​ is requested, which the browser will interpret as ''​your_site_url.html''​ and serve the cached content of Page 1.
  
  
-**Solution**:  ​Modify the theme'​s template with a single line change as the following example sm_market theme (located under app/​design/​frontend/​sm_market/​default/​template/​page/​html/​pager.phtml):​+====Solution==== 
 +Modify the theme'​s template with a single line change as in the following example sm_market theme (located under ''​app/​design/​frontend/​sm_market/​default/​template/​page/​html/​pager.phtml''​):
  
 Original Original
-  ​<?php foreach ($this->​getFramePages() as $_page): ?> +<​code>​ 
-           ​<?php if ($this->​isPageCurrent($_page)):​ ?> +<?php foreach ($this->​getFramePages() as $_page): ?> 
-                <li class="​current"><​a href="#"​ onclick="​javascript:​void(0);"><?​php echo $_page ?></​a></​li>​ +   ​<?php if ($this->​isPageCurrent($_page)):​ ?> 
-           ​<?php else: ?> + <li class="​current"><​a href="#"​ onclick="​javascript:​void(0);"><?​php echo $_page ?></​a></​li>​ 
-                <li class=""><​a href="<?​php echo $this->​getPageUrl($_page) ?>"><?​php echo $_page ?></​a></​li>​ +   ​<?php else: ?> 
-           ​<?php endif;?>​ + <li class=""><​a href="<?​php echo $this->​getPageUrl($_page) ?>"><?​php echo $_page ?></​a></​li>​ 
-  <?php endforeach;?>​+   ​<?php endif;?>​ 
 +<?php endforeach;?​
 +</code>
         ​         ​
 Modified to Modified to
-  ​<?php foreach ($this->​getFramePages() as $_page): ?> +<​code>​ 
-      <?php if ($this->​isPageCurrent($_page)):​ ?> +<?php foreach ($this->​getFramePages() as $_page): ?> 
-          <li class="​current"><​a href="<?​php echo $this->​getPageUrl($_page) ?>"><?​php echo $_page ?></​a></​li>​ + <?php if ($this->​isPageCurrent($_page)):​ ?> 
-      <?php else: ?> + <li class="​current"><​a href="<?​php echo $this->​getPageUrl($_page) ?>"><?​php echo $_page ?></​a></​li>​ 
-          <li class=""><​a href="<?​php echo $this->​getPageUrl($_page) ?>"><?​php echo $_page ?></​a></​li>​ + <?php else: ?> 
-      <?php endif;?>​ + <li class=""><​a href="<?​php echo $this->​getPageUrl($_page) ?>"><?​php echo $_page ?></​a></​li>​ 
-  <?php endforeach;?>​ + <?php endif;?>​ 
-         +<?php endforeach;?>​ 
-Which will now ensure that the full page URL is used for each page request. ​This guarantees that each HTML and AJAX request will have their own unique URL and therefore, ​their own unique cached ​copies.+</​code> ​        
 + 
 +This change ​will ensure that the full page URL is used for each page request. ​It guarantees that each HTML and AJAX request will have its own unique URL and therefore, ​its own unique cached ​copy.
  
-**Notes**: The sm_market theme appends additional information to the end of a URL to notify the back-end when it wants to make an AJAX request. For example, an AJAX request for page 2 of "test.html" ​would become ​"test.html?​p=2&​isLayerAjax=1" ​when using the sm_market theme. ​This appended information will vary from theme to theme.+====Notes==== 
 +The sm_market theme appends additional information to the end of a URL to notify the back-end when it wants to make an AJAX request. For example, an AJAX request for page 2 of ''​test.html'' ​would become ​''​test.html?​p=2&​isLayerAjax=1'' ​when using the sm_market theme. ​The appended information will vary from theme to theme.
  
  • Admin
  • Last modified: 2017/05/09 12:26
  • by Lisa Clarke