jQuery / jQuery Mobile 에서 json 파싱 방법
//이부분은 jQuery Mobile 시에 화면 로딩시 실행하라는 의미 입니다.
$('#화면ID').live('pageshow',function(event, ui){
/* 일반 jQuery일 경우 $(document).ready(function(){ */
//일단 자료를 넣을 div 비워둠.
$("#목록ul ID").empty();
//Ajax부분(getJSON 으로 쓰기도 함)
$.ajax({
type:'POST',
//json 파일 위치
url: 'url 넣어주세요.',
dataType: 'json',
timeout: 10000,
success: function(data){
// 데이터 목록일 경우의 for 함수
for(i=0; i<10; i++){
//jQuery Mobile 리스트 썸네일 프레임웍 레이아웃으로 구현시
document.getElementById("목록ul ID").innerHTML += '<li><img src="'+data[i].img+'.png"><h3>'+data[i].title+'</h3><p>'+data[i].content+'</p></li>';
}
},
//에러시 멘트
error: function(request, textStatus, errorThrown) {
alert('error:'+textStatus);
}
});
});
JSON 형식을 보면 [{"":""},{"컬럼명":"값"}] 형태일때 data[i].컬럼명 을 쓰시면 됩니다.
게시판 목록
팁게시판
디자인과 관련된 유용한 정보를 공유하세요.
질문은 상단의 QA에서 해주시기 바랍니다.
질문은 상단의 QA에서 해주시기 바랍니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 5152 |
senseme
|
12년 전 | 4146 | |
| 5151 |
senseme
|
12년 전 | 3729 | |
| 5150 |
프로프리랜서
|
12년 전 | 3122 | |
| 5149 |
프로프리랜서
|
12년 전 | 3964 | |
| 5148 |
프로프리랜서
|
12년 전 | 4353 | |
| 5147 |
프로프리랜서
|
12년 전 | 1584 | |
| 5146 |
senseme
|
12년 전 | 2711 | |
| 5145 |
senseme
|
12년 전 | 2701 | |
| 5144 |
senseme
|
12년 전 | 1239 | |
| 5143 | 12년 전 | 1274 | ||
| 5142 | 12년 전 | 8396 | ||
| 5141 |
senseme
|
12년 전 | 1505 | |
| 5140 |
senseme
|
12년 전 | 3740 | |
| 5139 |
senseme
|
12년 전 | 6326 | |
| 5138 |
senseme
|
12년 전 | 1546 | |
| 5137 | 12년 전 | 1131 | ||
| 5136 |
senseme
|
12년 전 | 1305 | |
| 5135 |
senseme
|
12년 전 | 3291 | |
| 5134 |
senseme
|
12년 전 | 1072 | |
| 5133 |
senseme
|
12년 전 | 1813 | |
| 5132 |
senseme
|
12년 전 | 1243 | |
| 5131 |
senseme
|
12년 전 | 902 | |
| 5130 | 12년 전 | 1393 | ||
| 5129 | 12년 전 | 2106 | ||
| 5128 |
senseme
|
12년 전 | 1377 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기