0
從第一次下拉列表中選擇狀態時,我不斷收到500內部服務器錯誤。你看到我的ajax調用有什麼問題嗎?嘗試執行時出現500內部服務器錯誤
function LoadCities() {
__state = $("ddlState option:selected").text();
$.ajax({
type: "POST",
url: "Default.aspx/LoadCitiesByState",
data: {'state': __state},
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
cache: false,
success: function() {
alert("Cities loaded");
},
fail: function() {
alert("Error.");
}
});
return false;
}
[WebMethod]
public void LoadCitiesByState(string state)
{
try
{
ListItem li = new ListItem();
li.Value = "0";
li.Text = "Select One";
DataTable dt = new DataTable();
dt = SharedDataAccess.GetCities(state);
ddlCity.DataSource = dt.Rows[0].Table.DefaultView;
ddlCity.DataValueField = "ListCity";
ddlCity.DataTextField = "ListCity";
ddlkCity.DataBind();
ddlCity.Items.Insert(0, li);
}
catch (Exception ex)
{
}
後臺會發生什麼? – PeeHaa
爲什麼不看看服務器的錯誤日誌,看看它認爲的問題是什麼? –
服務器端有問題 – Rafay