Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/02/2018, 13:11
yuo2
 
Fecha de Ingreso: diciembre-2008
Ubicación: PERU
Mensajes: 294
Antigüedad: 15 años, 4 meses
Puntos: 23
Pregunta traer resultado de un webmethod (C#)

Tengo un problema al traer el resultado de un webmethod .
Segun la traza que realizo, en c# veo que si trae la informacion, pero al momento de "pintar" o llevar el resultado a la pagina me arroja el error:
[object Object].
Nunca ingresa al success.

Código C:
Ver original
  1. public static object CargaInicial(String[] strParametros)
  2. {
  3. object strRetorno = null;
  4. ChoferesBL ChoferBL = new ChoferesBL();
  5. ChoferesDE _ChoferDE = new ChoferesDE();
  6. List<ChoferesDE> choferes = new List<ChoferesDE>();
  7. _ChoferDE.in_valor = strParametros[0];
  8. choferes = ChoferBL.ListarChoferes(_ChoferDE);
  9. strRetorno = new object[] { choferes };
  10.  
  11. JavaScriptSerializer serializer = new JavaScriptSerializer();
  12. serializer.MaxJsonLength = 500000000;
  13. return serializer.Serialize(strRetorno);
  14.  
  15. }

En javascript

Código Javascript:
Ver original
  1. jQuery(document).ready(function () {
  2.             dtChoferes();
  3.         });
  4.  
  5. function dtChoferes() {
  6.  
  7. var strParametros = new Array();
  8. strParametros[0] = "";
  9. $.ajax({
  10. url: "Page_Choferes.aspx/CargaInicial",
  11. type: "POST",
  12. contentType: "application/json; charset=utf-8",
  13. data: "{strParametros:" + JSON.stringify(strParametros) + "}",
  14. dataType: "json",
  15. success: function (res) { alert("ok"); },
  16. error: function (error) { alert(error); }
  17. });
  18. };