I'm using jQuery but my problem is that my page variable is being incremented several times even when I'm using "page += 1" in the .ajaxStop callback function because it's being executed more than once after the first time it's used. I use that variable as a parameter passed to the Flickr API to get a specific page of data.
What is happening is that the first time that function is called, the callback function is executed once. I then call the same function from a "more" button to get the next set of results but that time the function is called twice, the next time it's called thrice, and so on... That means that I can get page 1, 2, 4, 7, 11, etc...
The AJAX functions I'm calling are basically the .getJSON function and some extra .getJSON functions called in its callback method [inside getPhotos(id)]
// This gets the user ID from a given Flickr user page URL
function getUserID() {
??? $("#moreRow").hide(350);
??? var usr = document.getElementById('user').value
??? var Req_addr = 'http://api.flickr.com/services/rest/?method=flickr.urls.lookupUser&api_key=' + API_key + '&url=http%3A%2F%2Fflickr.com%2Fphotos%2F' + usr + json
??? $.getJSON(Req_addr, function(data) {
??? ??? // Once the user is known, data about its photos is requested???
??? ??? getPhotos(data.user.id)
??? });
??? // This hides the user data panel???
??? $("#userInfo").hide(0);
??? // This hides the settings panel???
??? $("#settings").hide(0, function() {
??? ??? $("#loader").slideDown(750);
??? });???
??? // This is what displays the photos when all of the AJAX requests have received their responses (ajaxStop)
?? ?$("#photos").ajaxStop(function() {
??? ??? // the page counter is incremented for the next page to be requested next time
??? ??? page += 1
??? ???
??? ??? // Add the data for the newly obtained photos to the table
??? ??? addPhotosToTable()
??? });
}
LP cores are MUCH lower power than Efficiency cores. Efficiency cores never really lived up to their name, but they did add a meaningful amount of performance in multithreaded loads, so Intel isn't going to remove them.
I don't usually say this, but WTF Microsoft?! Do you hate your customers, or do you just really not care at all? Windows Hello is one of the useful Windows features, and now you're effing it up.
Question
Argote
Hello everyone,
I'm using jQuery but my problem is that my page variable is being incremented several times even when I'm using "page += 1" in the .ajaxStop callback function because it's being executed more than once after the first time it's used. I use that variable as a parameter passed to the Flickr API to get a specific page of data.
What is happening is that the first time that function is called, the callback function is executed once. I then call the same function from a "more" button to get the next set of results but that time the function is called twice, the next time it's called thrice, and so on... That means that I can get page 1, 2, 4, 7, 11, etc...
The AJAX functions I'm calling are basically the .getJSON function and some extra .getJSON functions called in its callback method [inside getPhotos(id)]
Any hint as to what I'm doing wrong?
You can see the whole source here: http://luisargote.com/javascript/argote_flickr.js
Link to comment
https://www.neowin.net/forum/topic/955600-jquery-ajaxstop-callback-function-being-executed-multiple-times/Share on other sites
2 answers to this question
Recommended Posts