1👍
You should return serialized data in the view:
import json
def test(request):
result = {'result': True}
returned_json = json.dumps(result)
return HttpResponse(returned_json, mimetype="application/json")
And in your javascript:
var jq = jQuery.noConflict();
jq(document).ready(function(){
jq.ajax({
type: 'get',
url: '/realty/ajax/test/',
data: 'test',
success: function(data){
alert(data.result);
},
error: function(){
alert("error");
}
});
});
This is going to show you an alert with a true value.
Source:stackexchange.com