Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery refresh database results on click
    text
    copied!<p>I have this code in JQuery:</p> <pre><code>$().ready(function() { {exp:weblog:entries weblog="locations" show_expired="yes" show_future_entries="yes" orderby="date" sort="desc" limit="5" rdf="off" disable="member_data|trackbacks" status="open|featured|ongoing"} $('a.Favorites_Trigger_{entry_id}') .click (function() { $.get(this.href, function(data) { $('span.favoritesspan_{entry_id}').html(data); $('dl.favoritesul &gt; dd.entry_{entry_id}').replaceAll('dl.favoritesul &gt; dd.entry_{entry_id}'); }); return false; }); </code></pre> <p>What I am trying to do: when a link is clicked it currently updates a database in the main part of my page (call it widget.php), now widget.php also has a side bar where I want to show the new results of the triggered event that just took place. I click a link to say add or delete this favorite. It's basically a "my favorites" php module but I cannot seem to get the updated results once the link is clicked ever though the database change happens, I see that upon hard refresh of the browser. So is it possible to have that part refresh JQuery style?</p> <hr> <p>Thanks for the answer Soviut. It's actually for an Expression Engine Module and it calls the function to add/delete via click in file one and in file two it add or deletes function. The side bar is pulling the results, I'll call that file three. Thanks for taking a look.</p> <p>Code is below:</p> <p>File One:</p> <pre><code>{if logged_in} {exp:favorites:saved entry_id="{entry_id}"} {if saved} &lt;span class="favoritesspan_{entry_id}"&gt;&lt;em&gt;Saved as a favorite.&lt;/em&gt;&amp;nbsp;&lt;a class="Favorites_Trigger_{entry_id}" href="{path='features/favorite-add/'}{entry_id}/delete"&gt;Remove from favorites list?&lt;/a&gt;&lt;/span&gt; {/if} {if not_saved} &lt;span class="favoritesspan_{entry_id}"&gt;&lt;a class="Favorites_Trigger_{entry_id}" href="{path='features/favorite-add/'}{entry_id}/add"&gt;Add this item to your favorites?&lt;/a&gt;&lt;/span&gt; {/if} {/exp:favorites:saved} {/if} </code></pre> <p>File Two: (processor)</p> <pre><code>{exp:favorites:save weblog="funxyz"} </code></pre> <p>File Three:</p> <pre><code> &lt;dl class="favoritesul"&gt; {exp:favorites:entries weblog="funxyz" show_expired="yes" show_future_entries="yes" dynamic="off" status="open|featured|ongoing"} &lt;dd class="entry_{entry_id}"&gt;{title}&lt;/dd&gt; {/exp:favorites:entries} &lt;/dl&gt; </code></pre>
 

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