jQuery-Ajax autoComplete for Spring MVC not responding -


i trying use autocomplete of ajax in spring mvc application. had refered this. there issues in it. please guide me..

my script like..

    <script>  $(function() {     $( "#bname" ).autocomplete({         source: function( request, response ) {             $.ajax({                 url: "getbatchnames.jav",                 datatype: "json",                 data: {                         term: request.term                       },                 success: function( data ) {                                      response( $.map( data.batchnamelist, function( item ) {                         return {                             label: item.pinmasterbatchname,                             value: item.pinmasterbatchname                         };                     }));                 }             });         },         minlength: 1,         open: function() {             $( ).removeclass( "ui-corner-all" ).addclass( "ui-corner-top" );         },         close: function() {             $( ).removeclass( "ui-corner-top" ).addclass( "ui-corner-all" );         }     }); });  </script> .... <tr>                             <td width="95%">                             <div class="ui-widget">                                 <label style="width:35%;">batch name</label>                                 <form:input path="pinmasterbatchname" id="bname" class="txtbox"/>                                </div>                                 </td>                             </tr> 

the call going controller , returning map>.. describe had done..

in controller class

@requestmapping(value="/getbatchnames.jav", method = requestmethod.get)     @responsebody     public map<string, list<pinmasterdata>> getzipcodes()     {          system.out.println("helloooo");         list<pinmasterdata> batchnamelist = pinservice.listbatchesunderclient(45);         map<string, list<pinmasterdata>> pinmap = new hashmap<string, list<pinmasterdata>>();         pinmap.put("batchnamelist", batchnamelist);         return pinmap;     } 

and in model class class

public class pinmasterdata  {      @id     @generatedvalue     @column ( name = "id" )     private integer id;      @column ( name = "batchname" )     private string pinmasterbatchname;      @column ( name = "prefix" )     private string prefix; 

actually call going controller , returning list back. after jsp page not showing list beneath text field. problem? please guide me.. in advance

edit..

success: function( data ) {                     response( $.map( data.batchnamelist, function( item ) {                         return {                             label: item.pinmasterbatchname,                             value: item.pinmasterbatchname                         };                     }));                             alert("hai");                 }             }); 

i had tried this(for checking whether call backs ajax). not showing alert box too..

is control reaching success callback ? verify putting debugger statement below.

success: function( data ) {                          response( $.map( data.batchnamelist, function( item ) {             return {                 label: item.pinmasterbatchname,                 value: item.pinmasterbatchname }; 

chances not. try using complete callback. way know status being returned. jquery not consider ajax call success if there json parse error.

http://api.jquery.com/jquery.ajax/

look complete(jqxhr, textstatus)

edit

replace succcess this. execution should stop @ debugger provided call spring has returned. if has not returned @ server logs , see if call response failed reason. if return @ data object, should contain status of response ( note; don't rememeber exact key name. ). @ response text , copy responsetext , put in http://www.jsonlint.com , see valid json. ( hope familar firebug debugging in firefox ).

complete: function( jqxhr, textstatus ) {                          debugger;         response( $.map( data.batchnamelist, function( item ) {             return {                 label: item.pinmasterbatchname,                 value: item.pinmasterbatchname }; 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -