jquery-1.5.2.js를 사용하여 웹 응용 프로그램을 개발 중입니다. 업로드하려는 서버는 JSON 형식입니다. 4 개의 변수를 서버에 업로드하려고하는데 오류가 발생합니다. 여전히, 아래의 제안을 사용하여JSON을 사용하여 여러 데이터 업로드 - jQuery. 왜 일하지 않는거야?
--Updated 코드 그래도 작동하지 :
image= JSON.stringify(imageEncode, replacer);
name = JSON.stringify(name, replacer);
id = JSON.stringify(id, replacer);
comments = JSON.stringify(comments, replacer);
function data_post(){
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: "example/new.json",
data: "{'image': '" + image + "', 'name': '" + name + "', 'id': '" + id + "', 'comments': '" + comments + "'}",
success: function() {
alert('Successfully uploaded');
},
error: function() {
alert('Error on upload');
}
});}
이유는 아직 메시지에 "업로드에 오류"어떻게해야합니까 다음과 같이 내 코드는?
@mu 오류는 textStatus : "error thrown"및 textStatus : "Not Found"를 반환합니다. 이것은 애플 리케이션에 의해 매우 도움이되지 피드백입니다. – tasanoui
사실 그것은 도움이된다.'example/new.json'으로 무엇을해야할지 모르기 때문에 당신은 서버로부터 404를 얻고있다. –