0
데이터베이스에서 GirdView로 데이터를 가져 오는 응용 프로그램을 개발 중입니다. 이제 어떤 사용자가 도시 가져 오기를 클릭하면 특정 행의 도시 이름이 반환됩니다.URL이 자바 스크립트에서 정의되지 않았습니다.
그러나 나는 다음과 같은 오류가 점점 오전 :
<script>
$(document).ready(function() {
$("a").one("click", function (evt) {
debugger;
var stu_id = $(evt.target).closest("tr").children(":first-child").text();
$.ajax({
type: "POST",
url: 'WebForm1.aspx/get_city',
data: "{'stuid':'" + stu_id +"'}",
async: false,
contentType: "application/json; charset=utf-8",
success: function (final) {
debugger;
$("#LblCity").append(final.d + "<hr/>");
},
error: function() {
debugger;
alert('error');
}
});
});
});
</script>
내 다음 WebForm1.aspx.cs 페이지 코드 :
이 따르는 것은 내 스크립트 코드
[WebMethod]
public static string Get_City(int stuid)
{
MyDatabaseEntities MyDb = new MyDatabaseEntities();
var data = from db in MyDb.Students
where db.ID == stuid
select db.City;
return data.SingleOrDefault().ToString();
}
무엇이 오류입니까? 툴팁에 오류 메시지가 아닌'$ .ajax'에 대한 jQuery 소스가 표시됩니다. 콘솔을 확인 했습니까? –
죄송합니다. URL은 정의되지 않았습니다. @RoryMcCrossan –
@RoryMcCrossan Get City를 클릭해도 아무런 변화가 없습니다. 도와주세요. –