Revision 94fb8123 templates/poller.js

b/templates/poller.js
27 27
	}
28 28
    });
29 29
    $("#message").select();
30
    {% if user.is_authenticated %}
30 31
    updater.start();
31 32
    updater.poll();
33
    {% endif %}
32 34
});
33 35

  
34 36
function newMessage(form) {
......
52 54
}
53 55

  
54 56
jQuery.postJSON = function(url, args, callback) {
55
    args._xsrf = getCookie("_xsrf");
56
    $.ajax({url: url, data: $.param(args), dataType: "text", type: "POST",
57
    $.ajax({url: url, dataType: "text", type: "POST",
57 58
	    success: function(response) {
58 59
	if (callback) callback(eval("(" + response + ")"));
59 60
    }, error: function(response) {
......
90 91
    cursor: null,
91 92
    
92 93
    start: function() {
93
    	var args = {"_xsrf": getCookie("_xsrf")};
94
    	if (updater.cursor) args.cursor = updater.cursor;
95 94
    	$.ajax({url: "{% url fetch-existing %}", type: "POST", dataType: "text",
96
    		data: $.param(args), success: updater.onFetchExisting,
95
    		success: updater.onFetchExisting,
97 96
    		error: updater.onError});
98 97
        },
99 98
    
100 99
    poll: function() {
101
	var args = {"_xsrf": getCookie("_xsrf")};
102
	if (updater.cursor) args.cursor = updater.cursor;
100
	{% if user.is_authenticated %}
103 101
	$.ajax({url: "{% url fetch-updates %}", type: "POST", dataType: "text",
104
		data: $.param(args), success: updater.onSuccess,
102
		success: updater.onSuccess,
105 103
		error: updater.onError});
104
	{% endif %}
106 105
    },
107 106

  
108 107
    onSuccess: function(response) {

Also available in: Unified diff