I’ve already completed my wikipedia project and am woking on a better version of this. I have written all the code but what I’d really like to do is have a “more” button which outputs the next 10 results if/when the user clicks the “more” button.
I’m really struggling with the implementation of this, specifically getting the gsroffset value from the success function of my ajax call and then passing this into the code for the button on click. I’ve tried doing this in several different ways but the gsroffset value is always undefined when i console.log it inside the function for the ‘more’ button (its the correct value inside the ajax success function). I’m guessing that this might have to do something with the asynchronous nature of the ajax call.
Has anyone managed to get a more button working? Or does anyone have any ideas about how to fix this? I’m not too sure on how to resolve this with a callback and I don’t know anything about promises.
I have been using this codepen to try and get it to work - https://codepen.io/Jennah2121/pen/ZJorwO?editors=0011
Thanks in advance