Here is a sample response:
200: {"timestamp": 1402348389.349506, "messages": {"b": "more not working", "c": "i get it already", "a": "not working"}}WTF???
Here is the AJAX.
this.pollForUpdates = function() {
$.ajax({
type:"POST",
url:"{% url 'message_poller' %}",
data: {'lastmessage_received': this.last_received, 'address': this.getAddressJson() },
success : function(json) { doSomething(json)},
error : function(xhr,errmsg,err) {
alert(xhr.status + ": " + xhr.responseText + 'WTF???'); },
});
};
Return in view:
response = json.dumps({'messages': {"a": "not working", "b": "more not working", "c": "i get it already"}, "timestamp": time.time() })
return HttpResponse(response, content_type='application/javascript')
So I'm pretty much stumped here. All of my other AJAX POST calls work fine with the same HttpResponse.
To return for a JSON request:
return HttpResponse(response, content_type="application/json")
To return for a JSONP request:
return HttpResponse(response, content_type="application/javascript")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.