Click here to Skip to main content
15,743,179 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello There.
I am working on a small website and I need to send thread-post data through JSON.

This is the JSON object django serves:

[{"text":"Some sample text","id":"21","title":"Test Thread"}]

I saved this as a .js file and the following Javascript code works fine:

<script src=""></script>
      $.each(result, function(i, field){
        $("div").append(field.text + " ");

But when I change the getJSON url field to: - format:

It displays nothing. The web console of firefox does not display any errors either.

My view code is the following:
def thread_view(request, wall, Id):
    if request.method == 'GET':
        thread = api.get_thread(wall, Id)
        if thread != None:
            return HttpResponse(thread, content_type="application/json")
            return HttpResponse("No results")
        raise Http404

It takes information from the database and formats it into json using a simple serializer, and then sends the data.

What am I missing?

Extra info:

from bson import json_util
class JSONSerializer(object):
    def dumps(self, obj):
        return json_util.dumps(obj, separators=(',', ':')).encode('utf-8')

    def loads(self, data):
        return json_util.loads(data.decode('utf-8'))

I am using Django 1.6, JQuery 1.1, Python 2.7

When I enter the following url: firefox displays the JSON object just fine and it's exactly the same as the one in the js file.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900