I have a function on my page that uses ajax. The ajax goes to a Django view, which can then return some sort of data for me. Unfortunately, I can only get it to return one piece of data at the moment. The second gets returned as the string "success". Here's what I have going:
Ajax:
success: function(data, message) {
if(data === 'False'){
$('#mailsquare').css('background-color', '#A80000');
$('.dropdown-menu').prepend('<li class="message" id="{{item.id}}">'+message.substring(0,30)+'</li>');
} else {
$('#mailsquare').css('background-color', '#1b1b1b');
}
},
View:
@login_required
def checkMail(request):
user = request.user.get_profile()
i = inbox.objects.get(user = user)
read = i.read
new = i.message.order_by('created')[:1]
return HttpResponse(read, new)
The prepend statement doesn't use the "message" value that it is receiving, but rather just inserts the string "success". The "data" parameter is handled correctly.