반응형
jQuery ajax 콜은 PATCH를 지원합니까?
이 Ajax rquest를 보낼 때:
$.ajax({
headers : {
'Accept' : 'application/json',
'Content-Type' : 'application/json'
},
url : 'http://localhost:8080/wutup/venues/12',
type : 'PATCH',
data : JSON.stringify({description: "842490812321309213801923 gonzagazors"}),
success : function(response, textStatus, jqXhr) {
console.log("Venue Successfully Patched!");
},
error : function(jqXHR, textStatus, errorThrown) {
// log the error to the console
console.log("The following error occured: " + textStatus, errorThrown);
},
complete : function() {
console.log("Venue Patch Ran");
}
});
다음의 에러가 표시됩니다.
XMLHttpRequest는 http ://localhost:8080/wutup/venues/12를 로드할 수 없습니다.메서드 PATCH는 Access-Control-Allow-Methods에서 허용되지 않습니다.
단, 컬 사용:
$ curl -v -H "Accept: application/json" -H "Content-type: application/json" -X PATCH - d' {"address": "8421 Gonzaga Ave"}' http://localhost:8080/wutup/venues/12
About to connect() to localhost port 8080 (#0)
Trying 127.0.0.1... connected
Connected to localhost (127.0.0.1) port 8080 (#0)
PATCH /wutup/venues/12 HTTP/1.1
User-Agent: curl/7.21.1 (i686-pc-mingw32) libcurl/7.21.1 OpenSSL/0.9.8r zlib/1.2.3
Host: localhost:8080
Accept: application/json
Content-type: application/json
Content-Length: 57
HTTP/1.1 204 No Content
Server: Apache-Coyote/1.1
Access-Control-Allow-Origin: *
Date: Fri, 30 Nov 2012 08:14:35 GMT
Connection #0 to host localhost left intact
Closing connection #0
그$.ajax
메서드는 HTTP PATCH를 지원합니다.
지금 보고 계신 문제는ajax
메서드는 에서 패치를 검색합니다.Access-Control-Allow-Methods
옵션 비행 전 확인 응답 헤더.응답에 이 헤더가 없거나 PATCH 메서드가 이 헤더 값에 포함되지 않았습니다.어느 경우든 문제는 클라이언트 측 코드가 아닌 서버에 있습니다.
다음은 Java를 사용하는 예입니다.
response.addHeader("Access-Control-Allow-Methods", "GET, POST, PATCH, PUT, DELETE");
사용하시는 브라우저가 패치 방식을 지원하지 않는 경우가 있습니까?
jQuery AJAX API 문서에서 가져온 내용:
작성할 요청 유형("POST" 또는 "GET") 기본값은 "GET"입니다.주의: PUT 및 DELETE 등의 다른 HTTP 요청 방식도 사용할 수 있지만 모든 브라우저에서 지원되는 것은 아닙니다.
언급URL : https://stackoverflow.com/questions/13642044/does-the-jquery-ajax-call-support-patch
반응형
'programing' 카테고리의 다른 글
본문을 유효한 json으로 읽는 방법 (0) | 2023.02.26 |
---|---|
TypeScript 오류 "The operand of a 'delete' operand of a operator is optional?"의 배후에 있는 논리는 무엇입니까? (0) | 2023.02.26 |
Oracle 선택 항목에서 더 많은 열이 있는 테이블에 삽입 (0) | 2023.02.26 |
경고: imagejpeg() [function: imagejpeg]: gd-jpeg: JPEG 라이브러리에서 복구할 수 없는 오류가 보고됩니다. (0) | 2023.02.26 |
중력은 성공적인 형태 제출 시 화재 이벤트를 형성합니다. (0) | 2023.02.26 |