나는 아주 기본적인 질문을 알고 있지만, 내 하루 종일 낭비하고 나니 이것을 묻습니다. 난 그냥 장고에 다음 AngularJS와 코드를 사용하여 데이터를 보내고 :
$http.post('/data/creation',
{
html: 'a'
}).
success(function(data, status, headers, config) {
// this callback will be called asynchronously
// when the response is available
console.log(data);
console.log(status);
console.log(headers);
console.log(config);
}).
error(function(data, status, headers, config) {
// called asynchronously if an error occurs
// or server returns response with an error status.
console.log(status);
console.log(data);
});
과 장고에
가 :@csrf_exempt
def snippets_post(request):
html = False
css = False
js = False
JSONdata = False
response = "You're looking at the results of question %s."
if request.method == 'POST':
try:
JSONdata = request.POST.get('data', False) # it was [] in actual
except:
JSONdata = 'ERROR'
return HttpResponse(JSONdata)
내가 "응답, 으로 거짓 얻고 데이터를 대체하여 POST.get 결과에 HTML로입니다 동일 ". 나는 여기서 무엇이 잘못되고 있는지 모른다. 어느 누구도 여기에서 나를 도울 수 있습니까?
덕분에 우리는 $ HTTP의 POST를 사용하여 AngularJS와 데이터를 전송
사실
당신이 정적 값을 보내 주시기 바랍니다 수 및 확인 .. HttpResponse에를 반환 ("POST 값") .. 난 그것에 대해 의심하고 URL이이 스 니펫 또는 어딘가에 도달 했습니까? – Asik
POST.get이 '데이터'또는 'html'을 가져올 수 없기 때문에 의사 소통이 완벽하게 진행되고 있으며 False가 표시됩니다. 문제는 그것을 얻는 방법입니까? –
F12를 클릭하여 firebug 또는 chrome 네트워크 탭을 사용하여 요청을 추적하고 요청 처리 중에 URL에 html/data가 포함되어 있는지 확인하십시오. 문제가 서버 측 코드에있는 경우 ... – Asik