I have this code in JQuery:
$().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 > dd.entry_{entry_id}').replaceAll('dl.favoritesul > dd.entry_{entry_id}');
});
return false;
});
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?
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.
Code is below:
File One:
{if logged_in}
{exp:favorites:saved entry_id="{entry_id}"}
{if saved}
<span class="favoritesspan_{entry_id}"><em>Saved as a favorite.</em> <a class="Favorites_Trigger_{entry_id}" href="{path='features/favorite-add/'}{entry_id}/delete">Remove from favorites list?</a></span>
{/if}
{if not_saved}
<span class="favoritesspan_{entry_id}"><a class="Favorites_Trigger_{entry_id}" href="{path='features/favorite-add/'}{entry_id}/add">Add this item to your favorites?</a></span>
{/if}
{/exp:favorites:saved}
{/if}
File Two: (processor)
{exp:favorites:save weblog="funxyz"}
File Three:
<dl class="favoritesul">
{exp:favorites:entries weblog="funxyz" show_expired="yes" show_future_entries="yes" dynamic="off" status="open|featured|ongoing"}
<dd class="entry_{entry_id}">{title}</dd>
{/exp:favorites:entries}
</dl>