jq的ajax完整版本
$.ajax({ url: "GetCityByPId.ashx", data: {pId:pid}, dataType: "JSON", type: "GET", cache:false, success: function (data) { $("#city").empty(); for (var key in data) { var cityId = data[key].CityId; var cityName = data[key].CityName; $("#city").append("<option value=‘" + cityId + "‘>" + cityName + "</option>"); } }, error: function (XMLHttpRequest, textStatus, errorThrown) { //重点 这里可以查看报错信息 alert(XMLHttpRequest.status); alert(XMLHttpRequest.readyState); alert(textStatus); alert(errorThrown); } });
时间: 2024-10-10 01:08:13