Answer the question
In order to leave comments, you need to log in
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] ╧ЁюуЁрььр эр тр°хь їюёЄ-
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')
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);
}
)
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question