gpt4 book ai didi

.net - jQuery getJson() 无法在 ASP.NET MVC 中使用

转载 作者:行者123 更新时间:2023-12-01 03:54:53 24 4
gpt4 key购买 nike

我想使用 jQuery 对我的 MVC Controller 进行简单的调用。我能够调试服务器端,这意味着 Controller 接收到 ajax 调用并返回请求的信息。但是服务器端返回后客户端永远不会更新。当我使用FireBug调试脚本时,客户端卡在jquery-1.4.1.js的handle()中的event.isImmediatePropagationStopped()上。这是否意味着客户端根本没有得到回电?请帮忙。

$('#ToZip').blur(function() {
$.getJSON('http://localhost:3958/home/GetZipInfo?id=' + this.value,
function(result){
$("#ToCity").val = result.City;
$("#ToState").val = result.State;
}
)
});

public ActionResult GetZipInfo(string id)
{
// some code to prepare return value, zip
return Json(zip, JsonRequestBehavior.AllowGet);
}

提前致谢

最佳答案

您验证了您的 json 响应吗? http://api.jquery.com/jQuery.getJSON/状态:

As of jQuery 1.4, if the JSON file contains a syntax error, the request will usually fail silently.

直接在浏览器中打开处理程序,然后将其复制并粘贴到此处: http://www.jsonlint.com/

关于.net - jQuery getJson() 无法在 ASP.NET MVC 中使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3748908/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com