문법
.load( url [, data ] [, complete(responseText, textStatus, XMLHttpRequest) ] ) Returns: jQuery
-
urlType: StringA string containing the URL to which the request is sent.
-
dataType: PlainObject or StringA 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.
셈플
- subpage/page_01.php 내용1234567
<
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
>
- subpage/page_01.php의 모든 내용 출력12345
$(
"#button1"
).click(
function
(){
$(
"#div_1"
).load(
"subpage/page_01.php"
,
function
(res, status, xhr){
console.log( xhr );
});
});
- subpage/page_01.php의 모든 내용중 P Tag element만 출력12345
$(
"#button1"
).click(
function
(){
$(
"#div_1"
).load(
"subpage/page_01.php p"
,
function
(res, status, xhr){
console.log( xhr );
});
});
- subpage/page_01.php의 모든 내용중 P Tag, ID가 div_sub2인 element만 출력12345
$(
"#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 |