Im having an array
array(0=>12,1=>16,3=>20,4=>25);
And i have two buttons in my page
<button id="next">Next</button>
<button id="prev">Previous</button>
On a page load an ajax call will go with data 12 (first element of the array) and it fetches results for me..working fine
My issue is when i click the next button i need to pass 16 to the ajax call..(because 12 is the last submitted value) and again click next i need to pass 20 to the ajax
and if i click prev i need to pass 16 because 20 is the current value
So how do i know which element to pass to the ajax
heres my ajax
$.ajax({
url : baseurl+'/ajax/warehousedetails',
type:"post",
data:{"crid":<<<here i want to change>>>>},
success:function(data){
console.log(data);
}
});
Thank you
You can store the index of current element in a variable.
For example at a first time
So when you send a request first time use value
On the click of next
On the click of previous