【发布时间】:2015-08-29 03:10:17
【问题描述】:
HTML 索引.php
<a class="cart-icon" href="cart"></a>
<div class="content"></div>
Ajax 从 load-content/cart.php 加载内容
$(document).ready(function(){
$(document).on('click', '.cart-icon', function(e){
e.preventDefault();
var page = $(this).attr("href");
$('.content').load('load-content/'+page+'.php');
});
});
此代码将从 cart.php 加载内容,但不会更新 url,因此当我刷新页面时,该 div 中的内容会消失。我想要它,当我刷新页面时它不会消失并且还会更新 url。
例如: 默认网址:index.php,当我按下 a 标签时,它将从 cart.php 加载内容并将 url 更新为 index.php/load-content/cart.php
【问题讨论】: