Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8026939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:38:59+00:00 2026-06-04T23:38:59+00:00

I have an autocomplete in my MVC 4 application that connects to a database

  • 0

I have an autocomplete in my MVC 4 application that connects to a database of all the cities in the world (so you can imagine that its pretty large). It works fine on the PC, but when I go to the site on my smartphone, it takes a good 3 seconds to load and performance becomes really sluggish. Would using Ajax or JSON make it faster? Here’s the code (I’m using the code from the pluralsight tutorials):

Part of View + Javascript

<!--Searching through all the hotel locations -->
<p>Hotel Location (City): @Html.TextBoxFor(x => x.booking_instance.Location, 
   new { data_autocomplete = @Url.Action("QuickSearch", "Booking") })</p>

<script type="text/javascript">
$(document).ready(function () {        
    $(":input[data-autocomplete]").each(function () {
        $(this).autocomplete({ source: $(this).attr("data-autocomplete") }); 
    });
  }); 
</script>

Controller

// this is my database of cities.
TE_TSQL1_HBOSDataContext _db = new TE_TSQL1_HBOSDataContext(); 
public ActionResult QuickSearch(string term)
{
 var cities = _db.Cities
      .Where (r => r.CityName.Contains(term))
      .Select(r => new { label = (r.CityName + ", " + r.CountryName) });
 return Json(cities, JsonRequestBehavior.AllowGet); 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:39:01+00:00Added an answer on June 4, 2026 at 11:39 pm

    Yes! using Jquery and Ajax will definitely make it faster on your mobile phone as you wont have to load the full dataset into the phones memory and then search it. You can let the C# server do the select and then return just the data you want. The best part is, your server is already returning JSON results, and you can have the mobile device make its first query after 2 characters have been entered, greatly limiting the size of the dataset returned.

            $( ":input[data-autocomplete]" ).autocomplete({
                source: "controllerPath/QuickSearch",
                minLength: 2
    
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two jQuery autocomplete textboxes on a mvc web page. One that returns
I have autocomplete, that simply calls $.ajax. And when its getting result, it tries
I have an autocomplete text box that users can type an item code into
So I am working with ASP.Net MVC + jQuery autocomplete and I have a
I have autocomplete text box, that is JQuery based. when i record the macro,
I have an autocomplete event that fires correctly once a value is selected. I
I have a autocomplete textbox, in that textbox am getting employee names. If I
I have a simple autocomplete field that spits out a bunch of suggested words
I have a jQuery autocomplete input box for time. It lists all available times
I have made a textbox with an autocomplete in ASP.NET MVC 4, Javascript and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.