Note that there are some explanatory texts on larger screens.

plurals
  1. POWordpress Ajax for newbies
    primarykey
    data
    text
    <p>I am having issues particularly using Ajax post within an Ajax Post. Please enlighten me if this is possible.</p> <p>My scenario goes like this.</p> <p>I am using Wordpress and Bootstrap for my theme. I have a post type for "products" which I want to load using Ajax and have been successfully implemented them individually (for testing purposes) using <a href="https://stackoverflow.com/questions/15402239/how-to-load-wordpress-post-with-ajax-onclick">Wordpress post with Ajax on click</a> as well as using Bootstrap modal to load another Ajax post using <a href="http://wpquestions.com/question/showChrono/id/7922" rel="nofollow noreferrer">Modal via Ajax Post</a>.</p> <p>I am not a hardcore PHP nor jQuery programmer and I want to know if this 2 can be combined in one code which would be like:</p> <p>On first click will show the first Ajax post, and on the second click inside the first Ajax post will load Bootstrap modal via Ajax as well.</p> <p>Here are the format of my initial codes ---</p> <p>jQuery:</p> <pre><code>// AJAX POST / stackoverflow.com/questions/15402239/how-to-load-wordpress-post-with-ajax-onclick // Calls archieve-products.php $.ajaxSetup({cache:false}); $("a.ajax").click(function(){ var post_url = $(this).attr("href"); var post_id = $(this).attr("rel"); $("#brand-default").hide(); $("#brand-listing").show().html('&lt;div class="loading"&gt;&lt;/div&gt;'); $("#brand-listing").load(post_url); return false; }); // MODAL VIA AJAX POST / wpquestions.com/question/showChrono/id/7922 // Opens modal.php $('[data-toggle="modal"]').click(function(e) { e.preventDefault(); var href = $(this).attr('href'); if (href.indexOf('#') == 0) { $(href).modal('open'); } else { $.get(href, function(data) { $('&lt;div id="brands" class="modal hide fade"&gt;' + data + '&lt;/div&gt;').modal(); }); } }); </code></pre> <p>HREF from custom page template:</p> <pre><code>&lt;a href="&lt;?php echo $cpt_onomy-&gt;get_term_link( $term, $term-&gt;taxonomy ); ?&gt;" rel="&lt;?php the_ID(); ?&gt;" class="ajax"&gt; </code></pre> <p>HREF from archive page template:</p> <pre><code>&lt;a href="&lt;?php bloginfo('template_url');?&gt;/modal.php?ID=&lt;?php the_ID(); ?&gt;" data-toggle="modal"&gt; </code></pre> <p>I hope the codes I have provided is enough to help me. <strong>Many thanks in advance :)</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload