index.html에서 jquery를 이용해서 test.php에서 생성한 json 데이터를 읽어들이는 방법 !!
test.php
{
"name": "조호형",
"sex": "male"
}
index.html
<script>
$(document).ready(function() {
$('a#json').click(function() {
$.getJSON('test.php', function(jd) {
$('#pollok') .attr('style','display:')
.empty() .append('Name: ' + jd.name);
});
});
</script>
<a href="#" id="json">json</a>
<br />
<span id=pollok style="display:none;"></span>
$(document).ready(function() {
$('a#json').click(function() {
$.getJSON('test.php', function(jd) {
$('#pollok') .attr('style','display:')
.empty() .append('Name: ' + jd.name);
});
});
</script>
<a href="#" id="json">json</a>
<br />
<span id=pollok style="display:none;"></span>
댓글 없음:
댓글 쓰기