Not so hard. Do the following
1) register a custom handler on your download more link. For example, something like
$j('a[name=pageForward]').each(function() { $j(this).click(function(e) { e.preventDefault(); defaultPage++; doSearch(defaultPage); }); })
Notice that I added the name attribute to my anchor tags. DoSearch does:
2) causes ajax to load. also replace the contents of the download more with “Download” or something else
$.ajax({ url: url, data: queryString, dataType: json or xml, cache: false, beforeSend: function(xhr) { }, success: function(data, status, xhr) { }, error: function(xhr, status, errorText) { that.showNothing(); }, complete: function(xhr, status) { } });
Take a look at the jquery docs for $ .ajax for what each of them means. If you want, you can handle the dom modification in previous and subsequent callbacks of your register.
3) on ajax complete, fill in the data and change the link back (or delete the message "Download").
As a personal preference, I would disable the link in 2, and I will have a special div with the message "Download" with the download.
Also, something more advanced would be to create a jquery plugin for your swap view ...
hvgotcodes
source share