jquery - how to return a string[] in autocomplete error System.String[] -


my script in head

        var productnames;     $(document).ready(function () {         $("#inputsuccess2").autocomplete({             source: function (request, response) {                 var texttyped = $("#inputsuccess2").val();                 $.ajax({                     url: "@url.content("~/products/fetchname")",                     datatype: "json",                     data: "search=" + texttyped,                     type: "get",                     contenttype: "application/json; charset=utf-8",                     success: function (data) {                         var msg = assessments_jqueryautocomplete.autocomplete(request.term).value; //(ajaxpro functions)                         response(msg.d);                         response($.map(data, function (item) {                             return {                                   //value: '' + item                              }                         }                         ))                     },                     error: function (xmlhttprequest, textstatus, errorthrown) {                         alert("error: " + textstatus);                     }                 });             },             minlength: 1,             select: function (event, ui) {                  window.location = "/product/editsingleproduct?prdnm=" + ui.item.value;              }         }                 )     }); 

and controller is

  public  string[] fetchname(string search){   sqlconnection searchproduct = new sqlconnection(configurationmanager.connectionstrings["defaultconnection"].tostring());          searchproduct.open();         sqlcommand cmd = searchproduct.createcommand();         list<string> product1 = new list<string>();         cmd.commandtext = string.format("(select [productname],[producttype] [rush].[dbo].[product] productname '%{0}%')", search);         sqldatareader reader = cmd.executereader();          while (reader.read())         {             product1.add(reader.getstring(0));          }         searchproduct.close();         return product1.toarray(); } 

i getting parse error while manually check output system.string[]

so guess unable parse string[] in dropdown list because checked return value holding 11 items in array in advance

 public  jsonresult fetchname(string search){   sqlconnection searchproduct = new sqlconnection(configurationmanager.connectionstrings["defaultconnection"].tostring());          searchproduct.open();         sqlcommand cmd = searchproduct.createcommand();         list<string> product1 = new list<string>();         cmd.commandtext = string.format("(select [productname],[producttype] [rush].[dbo].[product] productname '%{0}%')", search);         sqldatareader reader = cmd.executereader();          while (reader.read())         {             product1.add(reader.getstring(0));          }         searchproduct.close();         return  json(product1.toarray(),jsonrequestbehavior.allowget); } 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -