c# - Consuming web service without ajax doesn't return all data -


i have problem went consume web service ajax, dont bring date especific data consulting database, went test web service in test mode work fine, here code, problem?

this webservice code

  [webmethod]       public string getname(string name)     {          var registeredusers = new list<person>();         string nombre = "";         string enstock = "";         int id = 1;         if (connect())         {               items oitem = (sapbobscom.items)ocompany.getbusinessobject(boobjecttypes.oitems);              if (oitem.getbykey(name))             {                nombre = oitem.itemname;                 enstock = oitem.quantityonstock.tostring();                 id = 3;              }             id = 0;         }         var json = "";           registeredusers.add(new person() { personid = id, name = nombre, stock = name });          var serializer = new javascriptserializer();         json = serializer.serialize(registeredusers);         return json;     } 

this image of result of web service in normal test result correct brings me data enter image description here

but went make test on ajax dont bring me data, problem? enter image description here

this web config code:

 <configuration>   <system.web>     <compilation debug="true" targetframework="4.5.2"/>     <httpruntime/>     <httpmodules>       <add name="applicationinsightswebtracking" type="microsoft.applicationinsights.web.applicationinsightshttpmodule, microsoft.ai.web"/>     </httpmodules>     <pages controlrenderingcompatibilityversion="4.0"/>   </system.web>   <system.codedom>     <compilers>       <compiler language="c#;cs;csharp" extension=".cs" type="microsoft.codedom.providers.dotnetcompilerplatform.csharpcodeprovider, microsoft.codedom.providers.dotnetcompilerplatform, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" warninglevel="4" compileroptions="/langversion:6 /nowarn:1659;1699;1701"/>       <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="microsoft.codedom.providers.dotnetcompilerplatform.vbcodeprovider, microsoft.codedom.providers.dotnetcompilerplatform, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" warninglevel="4" compileroptions="/langversion:14 /nowarn:41008 /define:_mytype=\&quot;web\&quot; /optioninfer+"/>     </compilers>   </system.codedom>   <system.webserver>     <validation validateintegratedmodeconfiguration="false"/>     <modules>       <remove name="applicationinsightswebtracking"/>       <add name="applicationinsightswebtracking" type="microsoft.applicationinsights.web.applicationinsightshttpmodule, microsoft.ai.web" precondition="managedhandler"/>     </modules>   </system.webserver> </configuration> 

this ajax html code

    <!doctype html> <html lang="en">   <head>     <meta charset="utf-8">      <script type="text/javascript" src="js1/jquery-1.4.2.min.js"></script>      <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>     <script type="text/javascript">    var datastring = 'name="1000066"';                    $.ajax({                           type: "post",                           url: "webservice1.asmx/getname",                           data: datastring,                           success: function(data) {                                  console.log(data);                             },                             error: function(xhr, status, error) {                                                       alert(error);                                                      alert(status);                               },                             complete: function(xdata, status) {                                    $('#txt').html($(xdata.responsexml).text()); // result                             }                          });        </script>       </head>    <body>    1000066    <div id="resultado_json"></div>    <div id="txt"></div>     <form target="_blank" action='http://190.185.126.6:8092/webservice1.asmx/getname' method="post">                                                  <table cellspacing="0" cellpadding="4" frame="box" bordercolor="#dcdcdc" rules="none" style="border-collapse: collapse;">                           <tr>     <td class="frmheader" background="#dcdcdc" style="border-right: 2px solid white;">parameter</td>     <td class="frmheader" background="#dcdcdc">value</td> </tr>                             <tr>                             <td class="frmtext" style="color: #000000; font-weight: normal;">name:</td>                             <td><input class="frminput" type="text" size="50" name="name"></td>                           </tr>                          <tr>                           <td></td>                           <td align="right"> <input type="submit" value="invoke" class="button"></td>                         </tr>                         </table>                       </form>      </body> </html> 


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -