반복사용하는 ajax() 메서드의 주요 속성을 ajaxSetup()에서 설정
.NET프로그래밍/jQuery 1.3.2 2009. 11. 17. 10:07 |
[jQuery.ajax.Setup.htm]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>반복사용하는 ajax() 메서드의 주요 속성을 ajaxSetup()에서 설정</title>
<style type="text/css">
.yellow { background-color:Yellow; }
.silver { background-color:Silver; }
</style>
<script src="../js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
// $.ajax()에서 반복 사용하는 속성을 상단에 설정 후 $.ajax에서 상속받아 사용
$.ajaxSetup({
url: "02.jQuery.getJSON.js", // a.aspx, a.php, a.jsp
dataType: "json"
});
$.ajax({
success: function(data) {
$.each(data, function() {
$('#tblList').append("<tr><td>" + this.Num + "</td><td>"
+ this["Name"] + "</td></tr>");
});
$('table:first tr:odd').addClass('yellow');
$('table:first tr:even').addClass('silver');
}
});
$.ajax({
success: function(data) {
$.each(data, function() {
$('#tblList2').append("<tr><td>" + this.Num + "</td><td>"
+ this["Name"] + "</td></tr>");
});
$('table:last tr:odd').addClass('yellow');
$('table:last tr:even').addClass('silver');
}
});
});
</script>
</head>
<body>
<table id="tblList" border="1"></table>
<table id="tblList2" border="1"></table>
</body>
</html>
-------------------------------------------------------------------------------------
[실행결과]
'.NET프로그래밍 > jQuery 1.3.2' 카테고리의 다른 글
Utilities - 양쪽 공백 제거 함수 : trim() (0) | 2009.11.17 |
---|---|
Utilities - 브라우저 정보 얻기 (0) | 2009.11.17 |
getJSON()을 대체하는 ajax() 메서드 (0) | 2009.11.17 |
getScript()메서드의 기능을 ajax()메서드로 대체 (0) | 2009.11.17 |
$.ajaxSetup() 메서드 정의 (0) | 2009.11.16 |