Im beginner in AJAX & JS so please bear with me.
I have an AJAX that will work in 2 events :
- When the page loaded
- When a button clicked
This AJAX have an url with some variables for pagination :
url: "http://localhost/myurl/" + keyword + "/" + limit + "/" + offset
This AJAX is working fine when the page loaded, but i dont know how to call/use it again when the user click the button.
And i put the .click function in the AJAX it self, so basically i need to recall the parent. This is a code to show you what i want to do :
$.ajax({
url: "example" + limit + offset
type: "GET",
error : function(jq, st, err) {
alert(st + " : " + err);
},
success: function(result){
$("#btnLoad").click(function(){
//recall this AJAX again here
offset = (page - 1) * limit;
page++;
});
}
});
I know copy-paste the code might work, but i dont want to do that because the AJAX is pretty long.
Any help is appreciated, Thanks :D
click()to be a new Javascript function. Re-use the new function onclick()and$(document).ready()