Global It Leader!!



 
 

Javasript Jsonp 크로스 도메인 jQuery, Ajax 예제

페이지 정보

작성자 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 0건 조회 5,796회 작성일 12-02-29 18:18

본문

jsonp.php
====================jsonp.php 소스===================================
<html>
<head>
<title>JSONP 테스트</title>
<meta http-equiv="content-type" content="text/html; charset=euc-kr">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script language="javascript">
$(function(){
    $("#btn1").click(function(){
 $.getJSON('http://도메인/getJsonp.php', 'callback=?', function(data){
     $.show(data);
 });
    });
 
    $("#btn2").click(function(){
        $.ajax({
            url : 'http://도메인/getJsonp.php'
            , dataType : 'jsonp'
            , jsonp : 'callback'
            , success : function(data){
                $.show(data);
            }
            , error: function(xhr){
                $.show(xhr);
            }
        });
    });
   
    $.show = function(data){
        $.each(data, function(key, val){
            $("#jsonp").append("<div>"+key + " : " + val +"</div>");
        });
    }
 
});
</script>
</head>
<body>
    <button id="btn1">테스트getJSON</button>
    <button id="btn2">테스트ajax</button>
    <div id="jsonp"></div>
</body>
</html>

========== getJsonp.php 소스 ============================
<?php
header("Content-Type:text/html;charset=EUC-KR");
?>
<?
$callback = $_GET["callback"];
echo "$callback ({'key1':'어머니','key2':'아버지'})";
?>

댓글목록

등록된 댓글이 없습니다.

전체 440
게시물 검색
컴퓨터언어 목록
번호 제목 글쓴이 조회 날짜
열람중 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5797 02-29
99 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5862 02-29
98 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5104 02-29
97 HTML no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5486 02-29
96 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5328 02-29
95 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 7168 02-29
94 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6199 02-28
93 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6043 02-28
92 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4963 02-28
91 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5275 02-27
90 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5805 02-27
89 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5990 02-27
88 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5536 02-22
87 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5063 02-26
86 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5298 02-21
85 CSS no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5185 02-17
84 CSS no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5178 02-17
83 HTML no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5515 02-17
82 CSS no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5001 02-17
81 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5342 02-14