0
내 Ajax 요청 형식의 문제점을 확인하려면 두 번째 눈을 빌려주시겠습니까?
가 우선이 같은 개체로 내 매개 변수를 전달 대신 값'Address'
의
$.getJSON('selectOne', {'modelClass': 'Address', 'id': '3'}, function(json, textStatus) {
$('span#address_line').append(json);
});
는 백 엔드로 전송되는 키
'modelClass'
내 서버 가져되었다 실제로 무엇을.
'3'
대신
'id'
과 같은 경우입니다.
$.getJSON('selectOne', ['Address', '3'], function(json, textStatus) {
$('span#address_line').append(json);
});
을 이제 두 파라미터 undefined
로 전송된다
절대로 작동하지 않습니다. 여기 뭐가 잘못 됐니?
제 백 엔드 서버는 cherrypy라는 파이썬 프레임 워크입니다.
편집 : 나는 여기 서버가 첫 번째 시나리오에 대한 불평 무엇을 붙여 넣습니다
500 Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request.
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/cherrypy/_cprequest.py", line 670, in respond
... ...
File "/home/njh/gui_Base.py", line 30, in selectOne
data_record = db.query(modelClass).filter(modelClass.id == id).one()
AttributeError: 'str' object has no attribute 'id'
첫 번째 예제에서는 객체'{'를 열고 배열']'을 닫습니다. 귀하의 질문이나 실제 코드에 오타가 있습니까? – Turnip
첫 번째 구문 오류는 한쪽 끝의 개체이고 다른 한쪽 끝의 배열이므로? 서버에서 어떻게 잡을 수 있는지 보여 주어야합니다. – adeneo
@Turnip, 주목 해 주셔서 감사합니다. 오타였습니다. 나는 그것을 바로 잡았다. –