多亏了StackOverflow,我成功地让下面的代码工作得很好,但我还有一个后续问题.
$.get('http://example.com/page/2/', function(data){
$(data).find('#reviews .card').appendTo('#reviews');
});
This code above enabled my site to fetch a second page of articles with a Load More button in WordPress. However when the site runs out of pages/results, I'm running into a small issue. The load more button remains in place. It will keep trying to fetch data even if no pages are remaining.
How can I tweak this command so that I can show a visual response if the .get
request fails or is a (404) not found page for instance?
如果有人能帮我举个简单的例子,哪怕是alert("woops!");
分,那就太棒了!
谢谢