我没有发现错误,但下面向您展示如何解决此任务。我认为您可以轻松地使其适应您的需求。
jQuery ajax部分:
<script type="text/javascript">function ajax_get_update() { $.get(url, function(results){ //get the parts of the result you want to update. Just select the needed parts of the response var table = $("table", results); var span = $("span.step-links", results); //update the ajax_table_result with the return value $('#ajax_table_result').html(table); $('.step-links').html(span); }, "html"); }//bind the corresponding links in your document to the ajax get function$( document ).ready( function() { $( '.step-links #prev' ).click( function(e) { e.preventDefault(); url = ($( '.step-links #prev' )[0].href); ajax_get_update(); }); $( '.step-links #next' ).click( function(e) { e.preventDefault(); url = ($( '.step-links #next' )[0].href); ajax_get_update(); });});//since the links are reloaded we have to bind the links again//to the actions$( document ).ajaxStop( function() { $( '.step-links #prev' ).click( function(e) { e.preventDefault(); url = ($( '.step-links #prev' )[0].href); ajax_get_update(); }); $( '.step-links #next' ).click( function(e) { e.preventDefault(); url = ($( '.step-links #next' )[0].href); ajax_get_update(); });});</script>模板html部分:
<div > <span > {% if object_list.has_previous %} <a id="prev" href="?{{ urlquerystring_previous_page }}">previous</a> {% else %} <span >previous</span> {% endif %} <span > Page {{ object_list.number }} of {{ object_list.paginator.num_pages }}. </span> {% if object_list.has_next %} <a id="next" href="?{{ urlquerystring_next_page }}">next</a> {% else %} <span >next</span> {% endif %} </span> </div> <form id="action-selecter" action="{{ request.path }}" method="POST"> <div id="ajax_table_result"> <table cellspacing="5"> <thead> {% table_header headers %} </thead> <tbody> ....


