1

我正在尝试使用 jquery 加载,将特定图像加载到 div 中,这就是我到目前为止所拥有的,不太有效:

$(document).ready(function () {  

$('#violin_img_1').load('http://www.klossal.com/klossviolins/inventory.html', function() {
    $(".violin:first").find('.photo').find('img');
});   


});

.inventory 页面中的 div 结构如下:

<div id="bow_cello-VictorFetique_1093" class="iso bow bow_cello instrument_container">
    <div class="about background_notselected">
        <div class="about_txt">
            <div class="about_summary">
                <h3>
                    Price: $15,000
                </h3>
                <br class="spacer">
                <h3>
                        A fine French cello bow branded: Vtor FETIQUE A PARIS, sold with ETIENNE VATELOT certificate.
                        81 Grams, round reddish brown Pernambuco stick, silver winding, silver mounted ebony frog.   
                </h3>
            </div>
            <h1>
                 Victor Fetique, 1093
            </h1>
            <h2>
                Cello Bow
            </h2>
        </div>
    </div>
    <div class="tile">
        <img class="inventory_tile_img" src="http://www.klossal.com/klossviolins/tiles/inventory_tile.png" alt="">
    </div>
    <div class="photo">
        <img class="instrument" src="http://www.klossal.com/klossviolins/instruments/bows/cellos/VictorFetique_1093.jpg" alt="">
        <div class="enlarge bc">
            <img class="enlarged_unselected" src="http://www.klossal.com/klossviolins/elements/fullscreen_unselected.png"/>
            <img class="enlarged_selected" src="http://www.klossal.com/klossviolins/elements/fullscreen_selected.png"/>
            <div id="VictorFetique_1093" class="enlarged_txt">Enlarge Image</div>
        </div> 
    </div>
</div> 
4

1 回答 1

4

好吧,如果你想访问那个元素,你应该像这样加载它:

$('#violin_img_1').load('http://www.klossal.com/klossviolins/inventory.html .violin:first .photo img')

你也是同一个域吗?:

由于浏览器安全限制,大部分“Ajax”请求都受同源策略的约束;请求无法从不同的域、子域或协议成功检索数据。

关联

于 2013-02-18T02:05:03.807 回答