当我在IIS上发布我的Web应用程序时,调用返回Json的操作方法并不是在调用 [英] Calling an action method that return Json is not woking when i publish my web application on IIS
本文介绍了当我在IIS上发布我的Web应用程序时,调用返回Json的操作方法并不是在调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的观点中有以下脚本: -
I have the following script on my view:-
<script type="text/javascript">
$(document).ready(function () {
$("#Rack_DataCenterID").change(function () {
var idDC = $(this).val();
$.getJSON("/Rack/LoadZoneByDataCenter", { id: idDC },
function (MedicineData) {
var select = $("#Rack_ZoneID");
select.empty();
select.append($('<option/>', {
value: null
}));
$.each(MedicineData, function (index, itemData) {
select.append($('<option/>', {
value: itemData.Value,
text: itemData.Text
}));
});
});
});
调用以下操作方法: -
Which calls the following action method:-
[CheckUserPermissions(Action = "Edit", Model = "Rack")]
public JsonResult LoadZoneByDataCenter(string id)
{
var zonelist = repository.getrealtedzone(Convert.ToInt32(id)).ToList();
var ZoneData = zonelist.Select(m => new SelectListItem()
{
Text = m.Name,
Value = m.ZoneID.ToString(),
});
return Json(ZoneData, JsonRequestBehavior.AllowGet);
}
以上运作良好,但在我将我的申请发布到iis之后上面停止工作,没有json数据将填充下拉列表。谁能建议导致这个问题的原因是什么?
谢谢
the above was working well , but after i have publish my application to iis the above stop working and no json data will populate the drop down . can anyone advice what is causing this problem ? Thanks
推荐答案
而不是这个 $。getJSON(/ Rack / LoadZoneByDataCenter, {id:idDC},
应该做
$.getJSON("@Url.Content("~/Rack/LoadZoneByDataCenter")", { id: idDC },
解析网址
这篇关于当我在IIS上发布我的Web应用程序时,调用返回Json的操作方法并不是在调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文