M
M
matveyvarg2016-01-26 22:19:03
JavaScript
matveyvarg, 2016-01-26 22:19:03

Why is there an error on ajax request?

The error itself:

Exception happened during processing of request from ('127.0.0.1', 60348)
Traceback (most recent call last):
  File "C:\Python27\lib\SocketServer.py", line 593, in process_request_thread
    self.finish_request(request, client_address)
  File "C:\Python27\lib\SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 99, in __init__
    super(WSGIRequestHandler, self).__init__(*args, **kwargs)
  File "C:\Python27\lib\SocketServer.py", line 651, in __init__
    self.finish()
  File "C:\Python27\lib\SocketServer.py", line 710, in finish
    self.wfile.close()
  File "C:\Python27\lib\socket.py", line 279, in close
    self.flush()
  File "C:\Python27\lib\socket.py", line 303, in flush
    self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 10053] ╧ЁюуЁрььр эр тр°хь їюёЄ-

The code:
from django.shortcuts import render,render_to_response
from django.http import JsonResponse,HttpResponse

# Create your views here.
def home(request):
  return render_to_response('index.html')
def get_url(request):
  url = request.GET[u'url']
  return HttpResponse('Some text')


and

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^$', 'base.views.home', name="home"),
    url(r'^get_url/$', 'base.views.get_url', name="get_url"),
]

$.get("http://localhost:8000/get_url/",{url:url_q},function(data){
        console.log('data');
        alert(data);
      }
    )

There is no response from the server. And the page reloads.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
matveyvarg, 2016-01-27
@matveyvarg

Found what the problem is. It was necessary to make a non-synchronous request, then everything is fine.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question