我在index.php上有一个产品列表,单击产品名称后,我想通过加载product_details.php页面及其内容和url来覆盖index.php的内容和url,而无需重新加载页面。
我使用下面的代码覆盖了url,但是我对如何加载内容一无所知。
$(document).on("click", ".view", function(e) {
e.preventDefault();
var url = $(this).attr(href);
history.pushState('obj', 'Product Details', url);
});
这是我想要的一个例子
你可以做这样的事情...
$(document).on(“ click”,“ .view”,function(e){
e.preventDefault();
var url = $(this).attr("href");
$('#loader').css("display","inline-block"); // display's a loader while loading
setTimeout(function() {
$("#products").load(url + " #details", function() {
history.replaceState('obj', 'Product_Details', url); });
}, 2000);
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句