[jQuery] jQuery.load

문법

    .load( url [, data ] [, complete(responseText, textStatus, XMLHttpRequest) ] )  Returns: jQuery
  • url
    Type: String
    A string containing the URL to which the request is sent.
  • data
    Type: PlainObject or String
    A plain object or string that is sent to the server with the request.
  • complete(responseText, textStatus, XMLHttpRequest)
    Type: Function()
    A callback function that is executed when the request completes.

셈플

  1. subpage/page_01.php 내용
    <div id="div_sub1"> 
        div: id=div_sub1
        <p> p: test 1</p>
        <p> p: test 2</p>
    </div>
    <div id="div_sub2"> div: id=div_sub2</div>
    <div id="div_sub3"> div: id=div_sub3</div>
    
  2. subpage/page_01.php의 모든 내용 출력
    $("#button1").click( function(){
        $("#div_1").load("subpage/page_01.php", function(res, status, xhr){
            console.log( xhr );
        });
    });
    
  3. subpage/page_01.php의 모든 내용중 P Tag element만 출력
    $("#button1").click( function(){
        $("#div_1").load("subpage/page_01.php p", function(res, status, xhr){
            console.log( xhr );
        });
    });
    
  4. subpage/page_01.php의 모든 내용중 P Tag, ID가 div_sub2인 element만 출력
    $("#button1").click( function(){
        $("#div_1").load("subpage/page_01.php p,#div_sub3", function(res, status, xhr){
            console.log( xhr );
        });
    });
    

 참고

"JavaScript / jQuery" 분류의 다른 글

[jQuery] jQuery가 지원하는 셀렉터들 (0)2014/01/02
[jQuery] DatePicker (0)2013/12/03
2014/01/03 12:45 2014/01/03 12:45
태그 : ,
글 걸기 주소 : 이 글에는 트랙백을 보낼 수 없습니다