Can't get JSON in CodePen, but can in Stack Overflow

Can't get JSON in CodePen, but can in Stack Overflow
0

#1

So here’s my project link - http://codepen.io/naregjan/pen/oYgjGr

I can’t get the entries to show up on CodePen, even though the JSON will show up in the console. It works in Stack Overflow’s editor, and won’t pull the JSON at all in JSFiddle. That’s ridiculous. What am I doing wrong? Has anyone encountered this?


#2

Ridiculous, I say :toilet:

The answer is quite simple, but easy to miss. Your button is doing what buttons do - submitting the page. Event handlers always pass event objects to the functions they call. We can prevent the default submit behavior by calling a function on the event object, aptly named event.preventDefault().

function(event) {
    event.preventDefault();
    var term = $("#term").val();
   // ... rest of stuff happens here
}