Click here to Skip to main content
11,803,495 members (72,272 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: MVC jQuery
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
Edited 7-Feb-13 16:50pm
Hesha at 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 at 11-Feb-13 1:39am
Thanks dude. but it also passing a Null value to controller. can you bit explain the jquery? Thanks
Hesha at 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 at 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 at 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
0 OriginalGriff 375
1 CPallini 290
2 F-ES Sitecore 270
3 Sergey Alexandrovich Kryukov 234
4 CHill60 220
0 OriginalGriff 3,000
1 Maciej Los 1,910
2 KrunalRohit 1,862
3 CPallini 1,755
4 Richard MacCutchan 1,187

Advertise | Privacy | Mobile
Web02 | 2.8.151002.1 | Last Updated 9 Feb 2013
Copyright © CodeProject, 1999-2015
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