jquery 로 웹서비스를 통해 처리하실려고 하신듯 싶은데요.
웹서비스 파일을 하나 생성합니다 . default.asmx 라고 하나 만들죠. 그리고 아래와 같이 배열 객체를 하나 만듭니다.
이를 jquery 로 호출하여 가져오도록 해보죠.
[WebMethod]
public Catalog[] GetCatalog()
{
Catalog[] catalog = new Catalog[1];
Catalog cat = new Catalog();
cat.Author = "Jim";
cat.BookName ="His Book";
catalog.SetValue(cat, 0);
return catalog;
}
아래는 jquery 를 호출하는 index.aspx 파일 안에 기술하시면 됩니다.
<script type="text/xxjavascript">
$(document).ready(function() {
$.ajax({
type: "POST",
url: "default.asmx/GetCatalog",
cache: false,
contentType: "application/json; charset=utf-8",
data: "{}",
dataType: "json",
success: handleHtml,
error: ajaxFailed
});
});
function handleHtml(data, status) {
for (var count in data.d) {
alert(data.d[count].Author);
alert(data.d[count].BookName);
}
}
function ajaxFailed(xmlRequest) {
alert(xmlRequest.status + ' \n\r ' +
xmlRequest.statusText + '\n\r' +
xmlRequest.responseText);
}
</script>
예제는 google 에서 쉽게 찾을 수 있답니다. 감사합니다.