새소식

Library/🥏 jQuery

[jQuery] ajax body에 json 담는 방법

  • -
728x90

🔥 TODO

👉 ajax body에 json 담는 방법은?

🧙 Solution

👉 아래에 기술된 코드를 이용하시면 됩니다.

crossdomain, accept 등은 옵션입니다. 상황에 따라 제거 또는 냅두셔도 됩니다.

var data= {
    "id":"han",
    "name" : "hoon"
}

$.ajax({
    type: "POST",
    crossdomain: true,
    accept: "application/json",
    contentType: "application/json; charset=utf-8",
	url : url,
	data : JSON.stringify(data),
	dataType : "json",
	success : function(data) {
		console.log('성공 - ', data);
	},
	error : function(e) {
		console.log('실패 - ', e);
	}
});

 

🏆 Result

👉 postman으로 테스트하는 경우, Body에 데이터를 담으시면 됩니다.

If I was of any help to you, please buy me coffee 😿😢😥

If you have any questions, please leave them in the comments

🧭 References

[1] reference : https://doctorson0309.tistory.com/

[2] Ads : https://play.google.com/store/apps/details?id=io.cordova.seoulfilter

 

 

 

 

 

 

반응형
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.