Basically I want to save a parameter that retrieves a value from a call to $ .post () as follows:
init = function(){
var lastpage = getLastPage();
}
function getLastPage(){
$.post("getInfo.php",{
last: "yes"
},
function(data){
setLast(data.last);
},'json');
return function setLast(data){
return data;
}
}
so when I reach the last message (last page), I have to check with the lastpage variable, which has the value returned by the getLastPage () function.
I am pretty blurring javascript pointer and thatβs it. Help the guys.
update (04/20/2010):
I did it the other way around:
init = function(){
getLastPage();
if((page+1) == $("#lastpage").val()){
alert("this is last post");
}else{
page++;
}
}
function getLastPage(){
$.post("getInfo.php",{
last: "yes"
},
function(data){
$("#lastpage").val(data.last);
},'json');
}
first run the function to temporarily save the value in the hidden input tag (lastpage), and then take that value again to check it when I press the forward button.
If you have a more suitable way, tell me.
source
share