Click here to Skip to main content
13,003,150 members (58,823 online)
Rate this:
Please Sign up or sign in to vote.
See more:
hi every one
i get a jquery for the Auto completion textbox and following query only pass null values to the controller .if you could assist me on this matter that would be a great help!!!

input id="searchTerm" name="searchTerm1" type="text" /> 
     <script type="text/javascript">
         $(function () {
                 source: "/Home/AutocompleteSuggestions",
                 minLength: 1,
                 select: function (event, ol) {
                     if (ol.item) {

//in controller class
 public JsonResult AutocompleteSuggestions(string ss)
            var suggestions = selectEmployees.getEmployeeSuggestedNames(ss);
            return Json(suggestions, JsonRequestBehavior.AllowGet);
Posted 7-Feb-13 16:48pm
Updated 7-Feb-13 16:50pm
Hesha 8-Feb-13 3:02am
i just notice that the valueget from the textbox is always null.i dntknow why this is happening? controller signature is working fine.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

This happen because in your script you provide only the url of the action but don't provide any value for [ss].
You must use another syntax that allow providing [ss] value in remote call, for example using a function as source for autocomplete and an explicit JSON call to remote server:
source: function( request, response ) {
          $.getJSON( "/Home/AutocompleteSuggestions", {
            ss: request.term
          }, response );

You can find more info on JQuery documentation about autocomplete and getJSON.
Hesha 11-Feb-13 1:39am
Thanks dude. but it also passing a Null value to controller. can you bit explain the jquery? Thanks
Hesha 11-Feb-13 1:57am
This is the suggested function i used : but still it returning Null vale :)

<script type="text/javascript">

source:(function (request, response ) {

$.getJSON( "/Home/AutocompleteSuggestions",{
ss: request.new1
minLength: 1,
select: function (event, ol) {
if (ol.item) {
Roberto Ferraris 11-Feb-13 4:31am
Hi, I've provided only the source: part of javascritp. It is intended to replace
source: "/Home/AutocompleteSuggestions",
not all the settings, minLength and select must remain outside of source: part.
Hesha 11-Feb-13 5:05am
Now its ok dude. i changed controller signature para as (String "term")then its getting the j query values from the view. i dnt know how this is happening but if i change that to any other name for para it will not be working :)
Thanks a Lot dude!!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170626.1 | Last Updated 9 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100