0
jquery ajax를 사용하여 django (개발 서버)에서 정적 파일 (js 스크립트)을 가져 오려고하지만 뭔가가 $.ajax
약속을 해결하지 못하고 있습니다. 호출되는 then
기능에
$.when(
$.ajax({dataType: "script", cache: true, url: "/static/ajax_upload/js/jquery.iframe-transport.js"}),
$.ajax({dataType: "script", cache: true, url: "/static/ajax_upload/js/ajax-upload-widget.js"})
).then(function() {
console.log("Load was performed.");
AjaxUploadWidget.autoDiscover();
$("#level-modal").foundation("reveal", "open");
}, function() { alert("An error occured, try reloading the page."); });
아무것도, 성공이나 실패 :
여기 내 아약스 전화입니다.
$.when(
$.ajax({dataType: "script", cache: true, url: "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"}),
$.ajax({dataType: "script", cache: true, url: "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"})
).then(function() {
console.log("Load was performed.");
AjaxUploadWidget.autoDiscover();
$("#level-modal").foundation("reveal", "open");
}, function() { alert("An error occured, try reloading the page."); });
내가 뭔가 내 응답 헤더 문제가 될 거라고 생각하지만 난 200 개 상태를 확인하고 난 전문가되지 않습니다 :
이상한 것은이 구글에서 파일과 같은 AJAX 호출이 작동하는 것입니다 HTTP. 장고에서
응답 : 구글에서
HTTP/1.0 200 OK
Date: Sat, 24 Jan 2015 22:57:35 GMT
Server: WSGIServer/0.1 Python/2.7.3
Last-Modified: Sat, 24 Jan 2015 18:45:52 GMT
Content-Length: 9476
Content-Type: application/javascript
응답 :
access-control-allow-origin:*
alternate-protocol:443:quic,p=0.02
cache-control:public, max-age=31536000
content-encoding:gzip
content-length:29524
content-type:text/javascript; charset=UTF-8
date:Sat, 24 Jan 2015 22:57:38 GMT
expires:Sun, 24 Jan 2016 22:57:38 GMT
last-modified:Fri, 19 Dec 2014 15:56:50 GMT
server:sffe
status:200 OK
timing-allow-origin:*
vary:Accept-Encoding
version:HTTP/1.1
x-content-type-options:nosniff
x-xss-protection:1; mode=block
에
DAJAXICE_XMLHTTPREQUEST_JS_IMPORT = False
을 추가하여 jQuery를 사용하는 사람들을 위해 해결 될 수 있다는 것을 발견? 필자가 생각하기에 dataType 스크립트에는 몇 가지 실패/오류 경고가 있습니다. '$ .ajax' 문서보기 – charlietfljquery에서 $ .getScript() 코드를 확인했으며 dataType 스크립트로 $ .ajax 호출을했습니다. 나는 그것을 시도했다. 그러나 그것은 같은 결과 다. 나는 $ .ajax(). done(). done() .with()와 always()를 사용하지 않고 독립적 인 호출을 시도했다. 그러나 같은 결과이다. django에서는 아무 일도 일어나지 않고 google – PhilipGarnero
맞다. '$ .ajax' 메소드는 '$ .when'이 작동하지 않거나 아약스 인 경우에 단지 궁금했습니다. 상대 경로에서 작동하지 않는 이유는 알 수 없습니다. – charlietfl