Google 애플리케이션 엔진에서이 애플리케이션이 google io talk에 나와있는 것과 유사한 작업을 수행하도록 앱을 설정하려고합니다. 이것은 기본적으로 완전히Google 애플리케이션 엔진에서 ajax 호출이 작동하지 않습니다.
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script language="JavaScript">
function startUpload(f){
if(typeof jQuery != 'undefined') { document.writeln("jQuery!"); } else { document.writeln("no jQuery :("); }
document.write("topwrite");
$.ajax({url:'http://projectid.appspot.com/getFileUploadEndpoint', cache: false, success: function (data){
document.write("i can write");
var fd = new FormData();
for(var n in data.params){ fd.append(n, data.params[n]); }
fd.append('file', f);
var xhr = new XMLHttpRequest();
xhr.upload.addEventListener('progress', function (evt){ $('#progress').text(evt.loaded+'/'+evt.total);}, false);
xhr.upload.addEventListener('load', function (evt){ $('#progress').text('Complete'); }, false);
xhr.open(data.method, data.url);
xhr.send(fd);
},
error: function(errorThrown){ document.write("didn't work did it"); document.write(errorThrown); } });
return true;
}
</script>
</head>
<body>
<form id="uploadbanner" enctype="multipart/form-data" onsubmit="return startUpload(myfile)">
<input id="fileupload" name="myfile" type="file" />
<input type="submit" value="submit" id="submit" />
</form>
</body>
</html>
은 내가 해당 URL로 이동하여 엔드 포인트 정보가 인쇄 볼 때마다 내가 새로 고침 시간만을 변경할 수 있기 때문에/getFileUploadEndpoint 잘 작동 알고있는 talk-에서 들어 올려 내 HTML 코드입니다 성공 함수 또는 오류 내부에서 실행하는 것 같다 (즉, "jQuery! topwrite"는 페이지간에 인쇄되지만 다른 것은 업로드하지 않고 업로드가 분명히 작동하지 않는다는 것을 알 수 있습니다.) 누군가 내가 뭘 잘못하고 있는지 말해 줄 수 있습니까?
성공 콜백은 어디에서 왔습니까? – artm
_ $. ajax_와 같은 줄에 있습니다. 오른쪽으로 스크롤해야합니다. 죄송합니다. –
jQuery .ajax 성공 콜백에서 새 XMLHttpRequest *를 인스턴스화하고 있습니까? 왜 그걸 할거야? 왜 .ajax()도 사용하지 않을까요? 그리고 더 나은 것은 promises API를 사용하여 첫번째 Ajax 호출을 성공적으로 완료 할 때 두 번째 Ajax 호출을 실행할 수 있다는 것입니다. –