1、ajax代码
1 function SelectSemesterBySchYear() { 2 // alert(‘sssssss‘); 3 var temp1 = document.getElementById("ctl00_ContentPlaceHolder1_Text_City").value; 4 $.ajax({ 5 type: "get", 7 url: "HospitalHandler.ashx?city=" + encodeURI(temp1),//要编码的地方 8 success: function (strJson) { 9 $("#ctl00_ContentPlaceHolder1_selectHospital").empty(); 10 $("#ctl00_ContentPlaceHolder1_selectHospital").prop("disabled", false); 11 var dataArray = eval(strJson); 12 for (var i = 0; i < dataArray.length; i++) { 13 $("#ctl00_ContentPlaceHolder1_selectHospital").append("<option value=‘" + dataArray[i].H_ID + "‘>" + dataArray[i].H_Name + "</option>"); 14 } 15 }, 16 error: function (XmlHttpRequest, textStatus, errorThrown) { 17 alert(XmlHttpRequest.responseText); 18 } 19 }); 20 }
2,ashx页面接收
1 string city = context.Server.UrlDecode(context.Request["city"].ToString());
3、不管怎么,要给JS先编码,保证传值时候不会出现乱码。
时间: 2024-10-09 23:33:17