Error with a getJSON call in jquery with ASP.NET MVC

Posted by Jedi Master Spooky on Stack Overflow See other posts from Stack Overflow or by Jedi Master Spooky
Published on 2010-03-08T12:42:45Z Indexed on 2010/03/08 13:36 UTC
Read the original article Hit count: 714

Filed under:
|

I have the following code in html, I cannot get the Function call back of JSON get call. Down is the code in controller. Please Help

 <script type="text/javascript"> 
     $().ready(function() {
         $("#CuitDespachante").typeWatch({ highlight: true, wait: 500, captureLength: -1, callback: finished });
    });

    function finished(txt) {
        $.getJSON('/Documentacion/GetDatosDespachantes', { cuitDespachante: txt },
                            function (data) {
                                alert('You typed: ');
                            }
        );

    };
</script>

public ActionResult GetDatosDespachantes(string cuitDespachante)
        {
            cuitDespachante = cuitDespachante.Replace("-", "").Replace("_", "");
            DepositarioFielWS.DepositarioFielWebService ws = new DepositarioFielWS.DepositarioFielWebService();
            var res = ws.GetDespachante(cuitDespachante);
            if (res.Licencia.CodigoLicencia == DepositarioFielWS.CodigoLicencia.Ok)
            {
                DepositarioFielWS.Despachante desp = new DepositarioFielWS.Despachante();
                desp.Cuit = res.Despachante.Cuit;
                desp.Nombre = res.Despachante.Nombre;


                var respuesta  =new
                {
                    cuit = desp.Cuit,
                    nombre = desp.Nombre

                };
                return Json(respuesta);
            }
            else
            {
                var respuesta = new
                {
                    cuit = cuitDespachante,
                    nombre = "Imposible Realizar Consulta"

                };
                return Json(respuesta);

            }
        }

© Stack Overflow or respective owner

Related posts about jquery-ajax

Related posts about asp.net-mvc