javascript - Loading php via ajax using jquery -
i'm trying load local pages inside of div. each menu link fetch corresponding content, contains php, via ajax , content displayed in div. of hosted on local server (my pc running xampp), develop theme in wordpress 4.2.2.
the jquery code i'm using following. added comments clarity:
jquery(mlinks).click( function(){ //mlinks array of links dom var tid=tabs.indexof(this); switch(tid){ //we find link has been clicked case 0: jquery("#tabcnt").load("http://localhost/project/a #tabcnt"); //load #tabcnt each page (a, b, c) break; case 1: jquery("#tabcnt").load("http://localhost/project/b #tabcnt"); break; case 2: jquery("#tabcnt").load("http://localhost/project/c #tabcnt"); break; } if((window.location.href == urlv)||(window.location.href == urlp)||(window.location.href == urlk)){ return false; } //if we're outside of addresses in urlv, urlk or urlp, behave normal anchor return; }); and pages loaded contain code:
get_header(); ?> <div id="tabcnt"> <div id="primary" class="content-area"> <?php do_action('slideshow_deploy', '100'); ?> <main id="main" class="site-main" role="main"> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'template-parts/content', 'page' ); ?> <?php // if comments open or have @ least 1 comment, load comment template if ( comments_open() || get_comments_number() ) : comments_template(); endif; ?> <?php endwhile; // end of loop. ?> </main><!-- #main --> </div><!-- #primary --> </div><!-- #tabcnt --> everything works want it, except line:
<?php do_action('slideshow_deploy', '100'); ?> it comes slideshow plugin. problem not specific of plugin, i've tried others.
i tried creating separate files containing similar line , loading document through iframe on target html, so:
<iframe src="slideshow_a.php"></iframe> this throws error.
i don't have expertise, think php code isn't being sent server when use ajax retrieve content.
any suggestions?
thanks!
Comments
Post a Comment