๋กœ์ผ“๐Ÿพ
๋ฐ˜์‘ํ˜•
var data = {"name":"John Doe"}
$.ajax({
	type : "post",
    url : "/test",
    dataType : "json", //์„œ๋ฒ„์—์„œ ๋ฐ›์„ ๋ฐ์ดํ„ฐ ํƒ€์ž…
    contentType: "application/json; charset=utf-8", //์„œ๋ฒ„๋กœ ๋ณด๋‚ด๋Š” ๋ฐ์ดํ„ฐ ํƒ€์ž…
    data : JSON.stringify(data),
    success : function(result) {
        alert(result.success); 
    },
    error: function(e){
    	alert("fail");
    }
});

 

๋งจ๋‚  ๊นŒ๋จน์–ด์„œ ์ œ๊ฐ€ ๋ณด๊ธฐ ์œ„ํ•ด ์”๋‹ˆ๋‹ค.

 

$.ajax({
  type : `http method type`,
  url : `url`,
  data : `์„œ๋ฒ„์— ์ „์†กํ•  ๋ฐ์ดํ„ฐ`,
  contentType : "์ „์†กํ•  ๋ฐ์ดํ„ฐ ํƒ€์ž…",
  //๊ธฐ๋ณธ ๊ฐ’ : "application / x-www-form-urlencoded; charset = UTF-8"  
  dataType : '์„œ๋ฒ„๋กœ ๋ถ€ํ„ฐ ์ˆ˜์‹ ํ•  ๋ฐ์ดํ„ฐ ํƒ€์ž…',
  //์•„๋ฌด๊ฒƒ๋„ ์ง€์ •ํ•˜์ง€ ์•Š์œผ๋ฉด jQuery๋Š” ์‘๋‹ต์˜ MIME ์œ ํ˜•์„ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•ด์„์„ ์‹œ๋„
  error : `์—๋Ÿฌ ๋ฐœ์ƒ์‹œ ์ˆ˜ํ–‰ํ•  ํ•จ์ˆ˜`,
  success : `์„ฑ๊ณต์‹œ ์ˆ˜ํ–‰ํ•  ํ•จ์ˆ˜`
});
๋ฐ˜์‘ํ˜•
profile on loading

Loading...