我在CenterDetail.aspx页面中有以下代码
function myFunction(id) {
console.log(2);
var myindex = window.ContentPlaceHolder1_ddCountryId.selectedIndex;
console.log(myindex);
var selectedName = window.ContentPlaceHolder1_ddCountryId.options[myindex].text;
console.log(selectedName);
var loc = window.location.href;
console.log(loc);
$.ajax({
type: "POST",
url: loc + "/BindState",
data: { id : id },
async: false,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
console.log(data);
}
});
}
以下方法在我的代码后面。
[WebMethod]
public static string BindState(int id)
{
var states = new StateProvinceCollection().Where(StateProvince.Columns.CountryId = Convert.ToString(id), true).ToList();
string tag = "<select id='StateProvinceId' name='StateProvinceName'>";
tag += "<option value=''>select</option>";
foreach (var item in states)
{
tag += "<option value='" + item.StateProvinceId + "'>" + item.StateProvinceName + "</option>";
}
tag += "</select>";
return tag;
}
一切仍然显示http://musicclass/Account/Management/Center/CenterDetail.aspx/BindState 404未找到错误。