1
我在html中有以下代码,我无法获取JSON获取调用的函数回调。向下是控制器中的代码。请帮助jQuery与ASP.NET MVC中的getJSON调用时出现错误
<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);
}
}
什么是错误或异常? – 2010-03-08 12:44:25
我没有得到一个错误或异常,我只是没有调用函数 – 2010-03-08 13:13:09
然后问题可能是路线。使用萤火虫“净”标签来确认(或者你会看到错误)。 – 2010-03-08 13:14:14