ajax - Django throws error no. 10053 when receiving POST from jQuery -



ajax - Django throws error no. 10053 when receiving POST from jQuery -

i'm trying out jquery send post , requests django.

so far recognized, , post errors, , although works cannot individual fields send django app.

so wonder what's problem, , how post work?

views.py

def xhr_test(request): if request.is_ajax(): if request.method == 'get': message = "hello ajax" print request.get print "hello" elif request.method == 'post': message = "hello post ajax" print request.post else: message = "hello" homecoming httpresponse(message)

template

<html> <head> <title>ajax jquery example</title> <script type="text/javascript" src="{{ media_url }}js/jquery.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#generate").click(function() { $.get("/ajax_fetch/xhr_test", function(data) { // alert(data); }); }); $("#generate_post").click(function() { $.post("/ajax_fetch/xhr_test", { name: "monty" }, function(data) { alert(data) }); }); }); </script> <style type="text/css"> #wrapper { width: 240px; height: 80px; margin: auto; padding: 10px; margin-top: 10px; border: 1px solid black; text-align: center; } </style> </head> <body> <div id="wrapper"> <div id="quote"><p> </p></div> <form method="get"> <p><input type="text" name="user" /></p> <p><input type="submit" id="generate" value="generate!" /></p> </form> <form method="post">{% csrf_token %} <p><input type="text" name="user" /></p> <p><input id="generate_post" type="submit" value="click" /></p> </form> </div </body> </html>

error trace

exception happened during processing of request ('127.0.0.1', 1625) traceback (most recent phone call last): file "c:\python27\lib\socketserver.py", line 284, in _handle_request_noblock self.process_request(request, client_address) file "c:\python27\lib\socketserver.py", line 310, in process_request self.finish_request(request, client_address) file "c:\python27\lib\socketserver.py", line 323, in finish_request self.requesthandlerclass(request, client_address, self) file "c:\python27\lib\site-packages\django\core\servers\basehttp.py", line 56 , in __init__ basehttprequesthandler.__init__(self, *args, **kwargs) file "c:\python27\lib\socketserver.py", line 641, in __init__ self.finish() file "c:\python27\lib\socketserver.py", line 694, in finish self.wfile.flush() file "c:\python27\lib\socket.py", line 301, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) error: [errno 10053] established connection aborted software in y ur host machine

there similar question

perhaps reply in settings.append_slash setting, redirects /ajax_fetch/xhr_test /ajax_fetch/xhr_test/. seek post info url slash @ end

jquery ajax django http

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -