About Django and DataTables AJAX load()

About Django and DataTables AJAX load()

ice916ice916 Posts: 2Questions: 2Answers: 0
edited March 2019 in Free community support

Hi everyone,

I'm using Django v.1.11 and DataTables v1.10.

I’d like to implement a Django project. This is the process, when clients choose a date on the UI, this will trigger Datatable’s Ajax function which connects to a custom url to get json data and to upgrade the tables’ data automatically on UI.

On the other hand, I wanna use a custom HTTP GET method that implements Django to response Ajax data via jsonresponse.

This is my sample code of the Ajax GET method:

Its used to update data by date that clients choose.

This is the errors what I got when I was testing.

The value "?_=1553449196872" is a wrong or a unexpected value.

Here is my questions,
1. how can I hide or avoid to get "?_=1553449196872" this value?
2. what kind of documents can I refer for this.

Thank for your assistances in advance.

Answers

  • kthorngrenkthorngren Posts: 21,117Questions: 26Answers: 4,916
    <?php _=1553449196872 ?>

    This is a jQuery Ajax option to disable the browser's cache.

    cache (default: true, false for dataType 'script' and 'jsonp')
    Type: Boolean
    If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET.

    You can change the ajax type to POST. Or if you want to use GET then add **kwargs to your Django function to accept the ?_=1553449196872 parameter.

    Kevin

This discussion has been closed.