Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Live Search using ASP.NET MVC and AJAX

I am looking to implement a live search in my MVC app similar to this site when you type in a question and results come up that are similar or like the search on http://www.krop.com/

I have the search code all working and results updated. I just need to know how to add the AJAX to the MVC framework (I know this site was built using it) so that when I type the results are updated.

I had this all working in normal ASP.NET Forms app.

like image 447
ddd Avatar asked Dec 29 '08 13:12

ddd


People also ask

Can we use Ajax in MVC?

Ajax namespaces can be combined with JavaScript and MVC partial views to create flexible interactive web pages with minimal code. When using these resources, developers should be aware of a few techniques necessary to create effective code.

Can Ajax work with ASP NET?

AJAX is used to create dynamic web pages that do not require page reloading when any part of the whole web page content or the whole web page content is changed. The server data exchange is asynchronous in nature and AJAX in ASP.net uses multiple technologies like XSLT, XHTML, CSS, JavaScript, etc.


1 Answers

what you need to do it attach to Jquery onchage event handler, and then call some ajax method of jquery ($.load , $.ajax etc...) and the information from a specified controller. asp.net mvc controller can return json results so you can later manipulate it in your javascript code.

if you have any other questions go ahead and ask.

like image 73
Orentet Avatar answered Oct 03 '22 07:10

Orentet