用django 开发的一个json webservice, 用jQuery发一个get 访问, 老是crash。 但如果用浏览器地址输入请求,能够返回数据,用AnjularJs也能返回数据。奇了怪! 用firefox 查看http request header,觉得唯一的差别是jQuery有: X-Requested-With:"XMLHttpRequest"
看来是Django对ajax支持不好?
错误信息如下:
----------------------
[07/Feb/2015 17:49:42] "GET /s/whereJquery2.htm HTTP/1.1" 200 1332
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 52491)
----------------------------------------
[07/Feb/2015 17:49:58] "GET /t/l/930871/?p=rhiu HTTP/1.1" 200 95
Traceback (most recent call last):
File "/usr/lib/python2.7/wsgiref/handlers.py", line 86, in run
self.finish_response()
File "/usr/lib/python2.7/wsgiref/handlers.py", line 128, in finish_response
self.write(data)
File "/usr/lib/python2.7/wsgiref/handlers.py", line 212, in write
self.send_headers()
File "/usr/lib/python2.7/wsgiref/handlers.py", line 270, in send_headers
self.send_preamble()
File "/usr/lib/python2.7/wsgiref/handlers.py", line 194, in send_preamble
'Date: %s\r\n' % format_date_time(time.time())
File "/usr/lib/python2.7/socket.py", line 324, in write
self.flush()
File "/usr/lib/python2.7/socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
[07/Feb/2015 17:49:58] "GET /t/l/930871/?p=rhiu HTTP/1.1" 500 59
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 593, in process_request_thread
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/lib/python2.7/dist-packages/django/core/servers/basehttp.py", line 129, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "/usr/lib/python2.7/SocketServer.py", line 651, in __init__
self.finish()
File "/usr/lib/python2.7/SocketServer.py", line 710, in finish
self.wfile.close()
File "/usr/lib/python2.7/socket.py", line 279, in close
self.flush()
File "/usr/lib/python2.7/socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe