로드 및 조각을 사용하여 몇 가지 선택 목록에 대한 옵션을로드하고 있습니다. 몇 가지 목적으로 jQuery로드 단편
이
내가 무엇을 가지고 :$(document).ready(function(){
$("#select1").load("ts.xml #select1",
function (responseText, textStatus, XMLHttpRequest) {
if (textStatus == "success") {
alert("Loaded select 1");
}
$("#select2").load("ts.xml #select2",
function (responseText, textStatus, XMLHttpRequest) {
if (textStatus == "success") {
alert("Loaded select 2");
}
});
을 그리고 내 HTML은 다음과 같습니다
ts.xml은 다음과 같습니다<li id="select1" class="left"></li>
<li id="select2" class="left"></li>
:
<select id="select1">
<option>Lorem</option>
<option>Ipsum</option>
<option>Lorem Ipsum</option>
</select>
<select id="select2">
<option>Lorem</option>
<option>Ipsum</option>
<option>Lorem Ipsum</option>
</select>
한 번 ts.xml을로드하고 fragm을 계속 검색 할 수 있습니까? 그것 밖으로 ent? 조각을 검색 할 때마다 ts.xml로드가 아닌 성공을 경고하고 싶습니다.
덕분에 많이
xml 캐시로 '응답'을 사용하여 select2를 불러올 수 있습니까? 나는 그것의 개념을 이해했다. 그러나 나는 그것을 만드는 법을 모른다. 그러므로 나는 질문했다. 고마워요. – jQuerybeast
@ adeneo의 대답은 그것을하는 방법 일 것입니다. 'response'를 jQuery 객체 (response = $ (responseText))로 변환하면 jQuery 메서드를 사용하여이를 파싱 할 수 있습니다. 그래서 # select2를 채울 필요가있을 때, 당신은 단지'response' 변수를 잡고 그것을 조작합니다. – swatkins