MegaMark16/django-live-support

add cache: false to ajax call

Opened this issue · 3 comments

Please add cache: false, to ajax call. Otherwise Chromium (Chrome) and I think ~ĨE8 will not be able to keep a communication alive.

greetings
ionic

more info on that.
cache: false, is the way to go.
But If set to false, it will force requested pages not to be cached by the browser. Setting cache to false also appends a query string parameter, "_=[TIMESTAMP]", to the URL.

this query string has to get removes in views.py -> def get_messages(request): method... otherwise server will fail with 500. after fixing this the application should work fine.

here are my modifications:

+changed to use jQuery 1.7.1 in admin + user area. This is not an easy task. but I think was good to fix Chrome behavoir. Not 100% sure about that...

in live_support.js about line ~40
var ajax_args = {
url: document.get_message_url,
data: args,
success: gotMessages,
error: getMessagesFailed,
cache: false, //for Chrome and IE8
dataType: 'json'
}

and in views.py -> def get_message(request):
about line ~83 change to:
for k, v in request.GET.iteritems():
alive = True
if(k.startswith('_')):
break

I did not paste and copy ... sorry maybe there are misstypings... my virtualbox is blocking copy paste :-( need to install guest additions again.

greetings
ionic

further in live_support.js ~line 30 change:
-- var last_message_id = $(item).find('.message_list li:last').attr('id').replace('message_', '');
++ var last_message_id = $(item).find('.message_list li:last').prop('id').replace('message_', '');

if you are going to use a jQuery >= 1.6 -> there have been some changes from attr to prop.

Cheers,
ionic