Answer the question
In order to leave comments, you need to log in
How to fix url error?
Hello, please help me understand.
There is a page in which I deduce the list of documents. A similar page has, for example, the following url address:
GET /documents/1/2009/ HTTP/1.1" 200 126071
where
1- категория документа
2009 - год создания документа
GET /documents/1/2009/edit/1120/ HTTP/1.1" 200 5755
POST /documents/1/2009/edit/1120/ HTTP/1.1" 200 169852
GET /documents/1/2009/edit/1120/?page=2&querystring_key=page HTTP/1.1" 200 5747
GET /documents/1/2009/?page=2&querystring_key=page HTTP/1.1" 200 5747
<div id="documents" class="dd">
<ol class="dd-list">
{% include page_template %}
</ol>
</div>
{% block script %}
{# START: AJAX request to endless pagination #}
<script type="text/javascript">
function activatePagination(){
$.endlessPaginate({
paginateOnScroll: true,
onCompleted: function(context, fragment) {
activateTooltip();
}
});
}
activatePagination();
</script>
{# END: AJAX request to endless pagination #}
<script src="{% static 'js/documents/crud.js'%}"></script> {# CRUD JS #}
{% endblock %}
$(function () {
$("#document-modal").on("submit", ".document-edit-form", function(e) {e.preventDefault(); saveForm.call(this, "Data successfully updated");});
var saveForm = function(success_message) {
var form = $(this);
var formData = new FormData(form[0]);
$.ajax({
url: form.attr("action"),
data: formData,
type: form.attr("method"),
dataType: 'json',
success: function (data) {
if (data.form_is_valid) {
// Update list of documents
$("#documents ol.dd-list").html(data.html_documents);
activatePagination();
// Hide modal
$("#document-modal").modal("hide");
// Show message to user
$("#user-action-message").fadeIn("slow");
setTimeout(function() {$("#user-action-message").fadeOut("slow");}, 2000);
}
},
cache: false,
contentType: false,
processData: false,
});
return false;
};
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question