Build a Wikipedia Viewer: why update page

Build a Wikipedia Viewer: why update page
0

#1

Hi everyone!
I have stuck.
In the console, I get a json object, but any changes doesn’t add to html .
I think, this is because my page update after click button “Find”.
How to fix it? Try Ajax?
I will be grateful for the help, the link to the project:

link


#2

You need to prevent the form from submitting. When the form submits it refreshes the page.

Change:

$('input[type="submit"]').click(function() {
    var text = $('input[type="search"]').val(),

to:

$('input[type="submit"]').click(function(event) { // note the event argument added
    event.preventDefault();
    var text = $('input[type="search"]').val(),

#3

it `s Magic. Thank you!
I trying so much variant…
I’ll go read the documentation for event.preventDefault ();


#4

You could avoided having to use the preventDefault() if you used a div instead of a form element.