V
V
Vladislav Sklyar2015-11-09 18:02:00
JavaScript
Vladislav Sklyar, 2015-11-09 18:02:00

How to implement ajax search on a page with a complex structure?

Good afternoon. You need to implement ajax search on the page. The page is complex with many different blocks and variables that are collected in one view. I read that you can do an ajax search in response to which the html code will be the answer, and then take one block from this html and replace it with a block on the current page. I tried to make it through .load, it didn’t work, the page jumps all the same. Is there such a way at all? Who has done this in practice? Help with links or code.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
maxfox, 2015-11-09
@VladSkliar

It's not clear what exactly didn't work.
As an option - make a container element on the page, write a separate template for it in jang. On an ajax request, render this template with the necessary data and send it. The client takes the html fragment and changes the contents of the container via .innerHTML. You don't even need jQuery.
Well, or in another way - give JSON from the server and render on the client. For example, through Handlebars. If you do not have a SPA, then frameworks like Angular are redundant.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question