I’m following the example, but I guess I’m missing something, because it doesn’t work
#views.py
def message(request):
if request.is_ajax():
message = "I'm in Ajax"
else:
message = "I'm NOT in Ajax"
return HTTPResponse(message)
#html
<script type="text/javascript">
$(document).ready(function() {
$.get("/message", function(data){
alert(data);
});
});
</script>
#urls.py
#Display Message
(r'^message/$', message),
When I refresh a page, nothing happend.
When I press F12 in Google Chrome in console it give’s me an error:
GET http://127.0.0.1:8000/message/ 500 (INTERNAL SERVER ERROR)
Django has no
HTTPResponseobject. You need to use aHttpResponseobject:and: