单击按钮时加载下一行
Load next row when i click the button
所以,下面的按钮的作用是显示 table posts($p) 的密钥,一旦我单击它,它就会显示当前 [=19= 的密钥].
<button type="button" onclick="location.href ='{$baseurl}/view/{$p.key}/';">Next Post</button>
但是,我想要做的是当我单击按钮 "Next Post" 以使用数据库中的键加载下一行时。
本项目在smarty上,上面这行代码位于somefile.tpl
您需要将侦听器附加到 click event to button, load data from server using ajax and then append 新数据到 html。
// Attach click listener
$("button").click(function(e){
// Prevent default behaviour
e.preventDefault();
// Load new data from server
$.ajax({
type:'GET',
url: '{$baseurl}/view/{$p.key}'
}).done(function(response){
// Do stuff with loaded data, for example append to body
$("body").append( $("<div>").text(response.toString()) );
}};
return false;
});
所以,下面的按钮的作用是显示 table posts($p) 的密钥,一旦我单击它,它就会显示当前 [=19= 的密钥].
<button type="button" onclick="location.href ='{$baseurl}/view/{$p.key}/';">Next Post</button>
但是,我想要做的是当我单击按钮 "Next Post" 以使用数据库中的键加载下一行时。
本项目在smarty上,上面这行代码位于somefile.tpl
您需要将侦听器附加到 click event to button, load data from server using ajax and then append 新数据到 html。
// Attach click listener
$("button").click(function(e){
// Prevent default behaviour
e.preventDefault();
// Load new data from server
$.ajax({
type:'GET',
url: '{$baseurl}/view/{$p.key}'
}).done(function(response){
// Do stuff with loaded data, for example append to body
$("body").append( $("<div>").text(response.toString()) );
}};
return false;
});