JQuery getJSON调用MVC Controller / Action但是在获取数据后没有执行所有函数 [英] JQuery getJSON call to MVC Controller/Action but not executing all function after get data
问题描述
这可能很简单。以下JQuery调用正在执行并调用控制器。控制器正在正确执行。我使用了注释掉的示例数据来验证模板是否也正常工作。
但是,(var response = data.location;)函数没有执行浏览器。我可以调试这个想法或其他方法吗?
Hi,
This is probably something simple. The following JQuery call is executing and calling the controller. The controller is executing correctly. I used the sample data that's commented out to verify that the templates were working also.
However, the (var response = data.location;) function is not executing in the browser. Any thoughts or other ways I can debug this?
function getLocations()
{
$.getJSON("/MapSearch/SearchLocationJson", function (data)
{
alert('show');
var response = data.location;
for (var i = response.length - 1; i >= 0; i--)
{
keywords.push(response[i]["StrLocation"]);
kLat.push(response[i]["StrLat"]);
kLng.push(response[i]["StrLng"]);
}
$("#suburbField").show();
$("#loadingLabel").hide();
});
}
SearchLocationJson Action执行良好但alert('show')没有执行。我用谷歌搜索但没有找到解决方案。请帮助。
我的行动代码是
SearchLocationJson Action execute well but alert('show') is not executing. i googled but not find the solution. Please help.
my action code is
public JsonResult SearchLocationJson()
{
var Getlocation = from r in odbe.ODB_LLg_Master
orderby r.Pcode descending
// select r;
select new
{
StrLocation = (r.A + "," + r.B+ "," + "VIC"),
StrL = r.L1,
StrL1 = r.L2
};
return Json(Getlocation, JsonRequestBehavior.AllowGet);
}
谢谢!
Thanks!
推荐答案
.getJSON( / MapSearch / SearchLocationJson,function(data)
{
alert(' show');
var response = data.loc ation;
for ( var i = response.length - 1 ; i > = 0 ; i--)
{
keywords.push(response [i] [ StrLocation]);
kLat.push(response [i] [ StrLat]);
kLng.push(response [i] [ StrLng跨度>]);
}
.getJSON("/MapSearch/SearchLocationJson", function (data) { alert('show'); var response = data.location; for (var i = response.length - 1; i >= 0; i--) { keywords.push(response[i]["StrLocation"]); kLat.push(response[i]["StrLat"]); kLng.push(response[i]["StrLng"]); }
( #suburbField) .show();
("#suburbField").show();
( #loadingLabel) 。隐藏();
});
}
("#loadingLabel").hide(); }); }
SearchLocationJson Action执行良好但alert('show')没有执行。我用谷歌搜索但没有找到解决方案。请帮助。
我的行动代码是
SearchLocationJson Action execute well but alert('show') is not executing. i googled but not find the solution. Please help.
my action code is
public JsonResult SearchLocationJson()
{
var Getlocation = from r in odbe.ODB_LLg_Master
orderby r.Pcode descending
// select r;
select new
{
StrLocation = (r.A + "," + r.B+ "," + "VIC"),
StrL = r.L1,
StrL1 = r.L2
};
return Json(Getlocation, JsonRequestBehavior.AllowGet);
}
谢谢!
Thanks!
这篇关于JQuery getJSON调用MVC Controller / Action但是在获取数据后没有执行所有函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!