摘要:AJAX template
要注意location.pathname.substr(1, location.pathname.length - 1) 出來的路徑
function GetDropdownlist() {
var City_ID = $("#" + id).val();
$.ajax({
type: "POST",
url: location.pathname.substr(1, location.pathname.length - 1) +"/GetDropdownlist",
data: "{p_strCity_ID: '" + City_ID + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
$("#ddlCity_" + id).empty();
var ojson = JSON.parse(result.d);
$("#ddlCity_" + id).append("<option></option>");
$(ojson).each(function () {
$("#ddlCity_" + id).append($("<option></option>").attr("value", this.intCity_ID).text(this.strCity_Name));
});
},
failure: function (response) {
alert('Ajax Error');
}
});
}