SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Jan 2013
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Send httpresponse to client

    Hi all,
    new here

    i have this python function
    Code Python:
    def gtest(request):
        p = request.POST
        print p
        g = p['information']
        print g
        to_json = {
            "key1": "value1",
            "key2": "value2"
        }
       jsonValidateReturn = simplejson.dumps({"jsonValidateReturn": "ddddd"})
        return HttpResponse(jsonValidateReturn, content_type='application/json' ,mimetype='application/json')

    and on the client side
    Code Javascript:
    $.ajax({
            url: "http://127.0.0.1:8000/api/gtest/",
            type: "POST",
            data: { information : "You have a very nice website, sir."},
            dataType: "json",
            success: function(data) {
            	alert ("post is success");
            },
            error: function(request,error) 
            { 
            alert(request.responseText);
            alert(error);
            }
        });

    no matter what i do when the post is back it goes to error.
    on my server i see this message
    "POST /api/gtest/ HTTP/1.1" 200 31
    so it looks like response should work but no matter what it does not go to the success function..

    plz help :\

    thx
    Guy
    Last edited by Mittineague; Feb 10, 2013 at 15:54. Reason: reformatting bbcode tags


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •