How to display different search results without page refresh - javascript

I'm writing an asp.net website that has a search. Depending on the filter that they apply, the results will be different (Look and Data displayed). Are partial views the best way to go about this? I don't want the page to have to refresh every time they apply a new filter.

Yes, partial view is best approach for this, use ajax call to load partial view.
Please refer for more details : https://stackoverflow.com/a/38968860/6606630

Perhaps you are reffering to Ajax tech?
Check this link: http://www.asp.net/ajax

Related

MVC5 Easiest way to search items and add to list using AJAX?

I'm trying to build a shopping cart type function where an order header is shown and the user can search and add items to a list.
I would prefer this be done using ajax to reduce postback time.
There are 3 table elements, Items, Order, Order_Items
So essentially a searchable list with add button/links on the left of the screen and a list area on the right which is then to be saved when alterations are finished?
is this best achieved with partial views passing to and fro? or using a view model all on one page that updates each others elements? or by another way that's easier?
Hoping someone can point me in the right direction and optimistically hoping for some example code to show its implementation.
Thanks in advance.
Found a great Ajax, MVC Partial view example here, covered everything I was looking for, hope it can help someone else.
Using Ajax and Jquery in MVC and Partial Views

Pass result of AJAX search form to a different view?

I can almost always find an answer searching stack overflow, but after many hours, I have come up blank. I am sure that I am doing something that should be easy, but complicating it for myself.
I have an "orders" index view with an AJAX search, sort and pagination. It's all set up based on this screen cast. Works fine.
However, I would like my users to be able to click a link to another page, which will be set up to print the results of the search, without the navigation, pagination, etc.
It seems the best way to do this is to have the new view perform the same search as was already performed on the index page.
I have created another route, action and view called print_list that is basically the same as the index page, but without the pagination, etc. Not very DRY, but for the purposes of this mockup, it's acceptable.
The question is how do I pass the AJAX search parameters to the other view? Basically, I need to pass the params into the link_to helper.
So for example:
<%=link_to "Print List", print_list_orders_path(:cat =>"name ", :search => "er", :range => "Forever") %>
renders:
Print List
...and that works fine, and passes those parameters. What I need is a way to be dynamically updating those params as the AJAX calls are made, and the Index page is updated. I could write a jQuery bit using:
$('.myLink').attr('href','/orders/print_list?cat=name+&range=Forever&search=er">');
and call it everytime the AJAX updates.(of course I would have to add the CSS class for that, obviously) However, that does not seem like the best way to do this, what with the hard coded path and all. Is there a more Railsy way?
I was also thinking that later in my development process, I wouldn't mind being able to save searches, so a method that could also be used to save the search for reuse later gets extra points.
Thanks for reading!
In case anyone ever has this problem - the solution is to use the rails session method, and store the search in the session.

Send value from one page to another

I have 2 pages say index.html and 2ndPage.html.
index.html has two textboxes and a button. Now i want to enter some data in the textboxes and received the data in 2ndpage.html. I want to use only javascript. dont want to use query string. Only post or get method. Is it possible? Please help me or guide me how to send and receive data form one page to another in javascript/jquery.
Well, using javascript or jquery you can accomplish that. Check jQuery's AJAX function. Otherwise, learn PHP as already mentioned in the comments.
using localStorage or sessionStorage you can do this. here is a link, which will help you. i just take few css property from one page to another page. but you can take input value also.
Taking css property from one html page to another page
or if you are taking care of old browser also then javascript Location object is the way to go.

jQuery pagination for json results

What is the best way of doing a pagination? I would also need to save the current page, so that when I click a link it would save the page I was on. So if I'm on page 2 of the pagination and click one link and then get back to pagination page it would remember that I was on page 2.
I get the results/data from Json request where I have offset and limit possibility.
$.getJSON(base_url+'/ajax/get_news/4/!OFFSET!/!LIMIT!/true', func...
Where !LIMIT! is how many results it shows and !OFFSET! is, well offset :D When I click a link, it makes that request, it goes throught the results and appends the result into page.
What is best way to save the page, cookies? Should I get all the results and then do the pagination somehow or do new request when user change page?
Some tutorial or "hands on" example would be awesome. Normal instructions/guides are difficult to undestand since my first language isn't english.
It appears you have two questions:
1) How to save page state (what page you are on): If the application must continue to use an ajax, then you should look at storing the state in the url as discribed here:
http://ajaxpatterns.org/Unique_URLs
2) Regarding where to do the pagination, I think it would depend on the size of the data to paginate. If it is small and you are not worried about the data changing on between paging, do it all in javascript. Otherwise, do it server-side.
Okey I should use the !OFFSET! and !LIMIT! to do the pagination. I just need change those numbers with pagination links (1 2 3 4 pages etc) to get the pagination to work I believe. But I dont know where to start :/

How To Display List of Sites One At A Time

I am looking for a way to display a list of websites one at a time from a URL list. I'm fine with a very manual solution, I found an AJAX solution where each "page" is displayed in a tab but it is very heavy because if I have 50 pages I want users to page through one at a time, this solution essentially pulls all 50 pages onto the one page. Do you know of a framework which does the same thing but only loads one page at a time? Thank you very much for the advice and help. Here is the site I found - http://css-tricks.com/jquery-ui-tabs-with-nextprevious/
You could load the URLs into an array and then create a 'next' button that loads the next url into a div; replacing the previous one.
do you require doing this will javascript?
might be easier to curl the pages using php, then echo this returned data as an eval-able array into the html. Then allow user to alter which part of the returned array you are looking at using a next and prev button.
if you pre-load each one it will be heavy as you have noted.
This idea is screaming for AJAX. With proper AJAX calls, you would only load a page once it has actually been selected by tab. Any previous page loaded into the area would need to be dumped. You shouldn't actually need to physically switch tabs if you're using the src attribute of an iframe, simply changing the src and forcing it to refresh itself should accomplish the trick. If you are performing a screen scrape through a remote web service, then you could simply use jQuery/AJAX to rewrite the innerHTML of the panel in question.

Categories