[英]Failed to load resource jquery function after published
在Visual Studio 2012中,我正在使用MVC 4和C#。 我有三個dropdownlist
。 每個都基於另一個具有綁定關系並與之相關聯,並且可以正常工作,但是在我發布后,由於我有一個jquery函數從jsonresult
讀取數據,並且它不允許訪問函數options.url = "/invoice/GETCompanyByID";
,所以它不起作用options.url = "/invoice/GETCompanyByID";
。
if ($("#Area").val() != "Please select") {
var options = {};
options.url = "/invoice/GETCompanyByID";
options.type = "POST";
options.data = JSON.stringify({ stateid: $("#Area").val() });
options.dataType = "json";
options.contentType = "application/json";
options.success = function (states) {
$("#state").empty();
$("#inv").empty();
for (var i = 0; i <= states.length; i++)
{
$("#state").append("<option selected value=" + states[i].Value + ">" + states[i].Text + "</option>")
$("#contract").val($("#state").val())
$("#state").prop("disabled", false);
}
};
options.error = function () { alert("Error retrieving states!"); };
$.ajax(options);
}
else {
$("#state").empty();
$("#state").prop("disabled", true);
}
$("#areaid").val($("#Area").val())
});
[HttpPost]
public JsonResult GETCompanyByID(int stateid)
{
return Json(new SelectList(DAL.Get_All_Contract(stateid), "IDContract", "ContractNo"));
}
終於我解決了我的錯誤
options.url = "/invoice/GETCompanyByID";
雖然我應該使用
Url.content("~/invoice/GETCompanyByID")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.