I am developing an application in which I am retrieving data from the database into GirdView. Now when any user clicks on the Get City, it should return the city name of that particular row.

But i am getting the following error:
Following is my script code:
<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>
My WebForm1.aspx.cs page code:
[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, not an error message. Have you checked the console?