使用ajax加载iframe

时间:2013-11-06 12:23:59

标签: wordpress jquery wordpress-plugin

我有一个WordPress网站。我正在使用Ajax加载我的所有页面和帖子。现在我需要使用Ajax加载地图。但是,它没有加载。刷新页面后,地图正在加载。我对它有疑问。

这是来自function.php文件的代码

$html.= '<li class="image_dsp '.$carousel_class.'" style="'.($count==1 ? "display:block;" : "display:none;").'" id="asset-tile-'.$p->ID.'">';
//Check the ID on contact page
if($p->ID==532){
$html.= '<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Sidra+Tower,+Dubai&amp;sll=25.107596,55.179241&amp;sspn=0.011289,0.021136&amp;ie=UTF8&amp;hq=&amp;hnear=Sidra+Tower&amp;t=m&amp;ll=25.107518,55.179348&amp;spn=0.027202,0.036478&amp;z=14&amp;output=embed"></iframe>';
}
$html.= '</li>';
}
print $html

我也使用过插件。并在我的页面中使用短代码。但是,它有同样的问题。

完整功能代码

<div class="single"> 
<?php  
if(count($get_posts)>0){ 
    $html.= '<div style="float:left; width:512px;" id="ajax_content">'; 
    $html.= '<ul class="thumbs">'; 
    foreach($get_posts as $p){ 
        if (has_post_thumbnail()){ //Edit by Yesh  
            $feat_image = wp_get_attachment_url(get_post_thumbnail_id($p->ID)); 
            $first_image = $count==1 ? ' first_image' : ''; 
            $carousel_class = "section-asset-photo {sort: 'type-00".$count."-000' } tile"; 
            $html.= '<li class="image_dsp '.$carousel_class.'" style="'.($count==1 ? "display:block;" : "display:none;").'" id="asset-tile-'.$p->ID.'"><a href="http://www.zaha-hadid.com/wp-content/files_mf/dsm5.jpg" target="_blank" class="slideshow"><img class="slickr-post'.$first_image.'" src="'.$feat_image.'"/></a></li>'; 
            // set up image contents 
            if($count==1){ 
                $default_active = $p->ID; 
                $slider_content = $p->post_content; 
                $slider_content = apply_filters('the_content', $slider_content); 
                //$slider_content = str_replace(']]>', ']]&gt;', $slider_content); 
                $slider_content = do_shortcode($slider_content); 
            } 
            if(count($get_posts)>1){ 
                $navigation.= '<a href="#" id="'.$p->ID.'" class="load-page'.($default_active==$p->ID ? ' activeSlide' : '').' '.$p->ID.'">'.$count.'</a>'; 
            } 
            $pathinfo = pathinfo($feat_image); 
            $big_image = $pathinfo['dirname'].'/'.$pathinfo['filename'].'_big.'.$pathinfo['extension']; 
            $gallery_li[$p->ID] = array( 
                    'medium_image'=>$feat_image, 
                    //'large_image'=>'http://www.zaha-hadid.com/wp-content/files_mf/cache/th_65d1300db123ce22f6e2569fb36764f8_dsm5.jpg' 
            ); 
            $js_script.= 'myimages['.$post_id.']['.($count-1).'] = "'.$p->ID.'";'; 
            $count++; 
        }else{ 
            $carousel_class = "section-asset-photo {sort: 'type-00".$count."-000' } tile"; 
            // set up image contents 
            if($count==1){ 
                $default_active = $p->ID; 
                $slider_content = $p->post_content; 
                $slider_content = apply_filters('the_content', $slider_content); 
                // $slider_content = str_replace(']]>', ']]&gt;', $slider_content); 
                $slider_content = do_shortcode($slider_content); 
            } 
            $html.= '<li class="image_dsp '.$carousel_class.'" style="'.($count==1 ? "display:block;" : "display:none;").'" id="asset-tile-'.$p->ID.'">'; 
            // Check the ID on contact page 
            if($p->ID==532){ 
                $html.= '<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Sidra+Tower,+Dubai&amp;sll=25.107596,55.179241&amp;sspn=0.011289,0.021136&amp;ie=UTF8&amp;hq=&amp;hnear=Sidra+Tower&amp;t=m&amp;ll=25.107518,55.179348&amp;spn=0.027202,0.036478&amp;z=14&amp;output=embed"></iframe>'; 
            } 
            $html.= '</li>'; 
            $count++; 
        } 
    } 
    $html.= '</ul></div>'; 
    $html.= '<div class="project_desc">'; 
    $html.= $slider_content; 
    $html.= '</div>'; 
    $html.= '<div class="smooth_nav">'; 
    $html.= $navigation; 
    $html.= '</div>'; 
} 
print $html; 

0 个答案:

没有答案