jquery - how can i do not send optional params from ajax to c# function? -


i have following function on webservice 3 optional params:

    [webmethod]     [scriptmethod(responseformat = responseformat.json)]     public string obtenirpoble(string cp = "", int codi = 0, string nom = "")     {         list<clspoble> llista = _r.getlistpobles(cp, codi, nom);         javascriptserializer jss = new javascriptserializer();         string resultat_json = jss.serialize(llista);         return resultat_json;     } 

the problem not make optional params because make on webservice.
problem when i'm sending ajax call using json 1 param because trigger error before run webservice code

            //object send             var dataobject = {};             dataobject[config.busqueda] = $(elemid).val();               var json = json.stringify(dataobject);              $(elemid).autocomplete({                 source: function (request, response) {                     $.ajax({                         url: config.webservice,                         data: json,                         datatype: "json",                         type: "post",                         contenttype: "application/json; charset=utf-8",                         success: function (data) {                             //code...                         }                                                 });                 }              }); 

and following error "invalid call web service. missing value parameter".
know can solve sending default values of params question if possible send 1 param , how can this?


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -