로드시 jquery 스크립트를 실행하는 ASP.net mvc 페이지가 있습니다. 스크립트는 컨트롤러에서 작업을 호출하고 드롭 다운 목록을 수화합니다.페이지로드시 jquery 스크립트가 실행되지 않습니다.
이것은 내 dev 컴퓨터에서 작동하지만 웹 서버 (IIS 6을 실행하는 Win 2k3 상자)에 배포하면 페이지가로드되지만 스크립트가 실행되어 빈 드롭 다운 목록이 표시됩니다.
나는 scripts 폴더에 jquery-1.3.2.js 파일이 있고 웹 서버에 aspnet_isapi.dll에 매핑을 추가했습니다. 내가 놓친 다른 것이 있습니까?
이것은 내 컴퓨터에서 작동하지만 웹 서버에서 작동하는 드롭 다운 목록을 보완하는 페이지의 일부입니다. 스크립트가 ApplicationSettings 컨트롤러를 호출하여 해당 JSON 객체를 해독하는 JSON 객체를 얻을 수 있습니다. 당신은 당신의 코드를 삽입 다운 목록
<asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" runat="server">
<script src="~/Scripts/jquery-1.3.2.js" type="text/javascript"></script>
<script type="text/javascript">
// Wait for the document to be ready
$(document).ready(function()
{
var selectedApp = $('#selectedApplication').val();
var selectedMac = $('#selectedMachine').val();
// Get the list of applications and populate the applications drop down list
$.getJSON("/ApplicationSettings/Applications/List", function(data)
{
var items = "<option>----------- Select Application to Configure ----------</option>";
$.each(data, function(i, application)
{
var selected = (application.Value == selectedApp) ? 'selected' : '';
items += "<option value='" + application.Value + "'" + selected + ">" + application.Text + "</option>";
});
$("#Applications").html(items);
});
// Get the list of machines where the selected application is installed and populate the machines drop down list
$("#Applications").change(function()
{
if ($("#Applications").attr("value") != "")
{
// Enable the Machines DDL if a valid application is selected
$("#Machines").removeAttr("disabled");
// Populate the machines DDL with a list of machines where the selected application is installed
$.getJSON("/ApplicationSettings/Machines/List/" + $("#Applications > option:selected").attr("value"), function(data)
{
// Set the first item in the list
var items = "<option>---------- Select Machine -----------</option>";
// Retrieve the list of machines for th selected application from the database
$.each(data, function(i, machine)
{
var selected = (machine.Value == selectedMac) ? 'selected' : '';
items += "<option value='" + machine.Value + "'" + selected + ">" + machine.Text + "</option>";
});
// Add the items retrieved to the Machines DDL
$("#Machines").html(items);
if ($("#Machines").attr("value") != "")
{
$("#btnSearch").removeAttr("disabled");
}
else
{
$("#btnSearch").attr("disabled", "disabled");
}
});
}
else
{
// If a valid application has not been selected then disable the Machines DDL
$("#Machines").attr("disabled", "disabled");
$("#btnSearch").attr("disabled", "disabled");
}
});
if (selectedApp != "")
{
$("#Machines").removeAttr("disabled");
$.getJSON("/ApplicationSettings/Machines/List/" + selectedApp, function(data)
{
var items = "<option>---------- Select Machine -----------</option>";
$.each(data, function(i, machine)
{
var selected = (machine.Value == selectedMac) ? 'selected' : '';
items += "<option value='" + machine.Value + "'" + selected + ">" + machine.Text + "</option>";
});
$("#Machines").html(items);
});
if (selectedMac != "")
{
$("#btnSearch").removeAttr("disabled");
}
else
{
$("#btnSearch").attr("disabled", "disabled");
}
}
else
{
$("#Machines").attr("disabled", "disabled");
$("#btnSearch").attr("disabled", "disabled");
}
});
function saveSelectedApplication()
{
$("#selectedApplication").val("");
$("#selectedMachine").val("");
$("#selectedApplication").val($("#Applications").attr("value"));
if ($("#Applications").attr("value") != "")
{
$("#Machines").removeAttr("disabled");
if ($("#Machines").attr("value") != "")
{
$("#btnSearch").removeAttr("disabled");
}
else
{
$("#btnSearch").attr("disabled", "disabled");
}
}
else
{
$("#Machines").attr("disabled", "disabled");
$("#btnSearch").attr("disabled", "disabled");
}
}
function saveSelectedMachine()
{
$("#selectedMachine").val("");
$("#selectedMachine").val($("#Machines").attr("value"));
if ($("#Machines").attr("value") != "")
{
$("#btnSearch").removeAttr("disabled");
}
else
{
$("#btnSearch").attr("disabled", "disabled");
}
}
</script>
스크립트가 실행되고 있습니까? 스크립트 맨 위에서 간단한 경고? – littlechris
global.asax 파일에서 맞춤 라우팅을 사용합니까? 아래에 남긴 주석은 아래에 구현할 때까지 내가 가진 오류와 같습니다. 나는 JS가 내 스크립트 경로에 문제가있어 너무 일찍 돌아가고 있다고 생각한다. 내가 \t \t \t $ .getJSON ("../ ApplicationSettings로 변경하는 경우 – littlechris
스크립트는 줄 $ .getJSON ("/ ApplicationSettings/응용 프로그램/목록 ", 기능 (데이터) 를 작업의 위치에 문제가 있었다/응용 프로그램/목록 ", 함수 (데이터) 그것은 작동합니까 내가 정말로해야 할 일은 올바르게 행동 경로를 해결할 수있을 것 같아요. jquery에서 이것을 수행하는 방법을 모르십니까? 아이디어가 있습니까? – user99513