JavaScript & jQuery & Ajax

[Ajax] ajaxSetup()

라임오렌지원 2022. 10. 5. 11:08

Ajax 요청에 대한 기본값을 설정한다.

다만, 사용을 권장하지 않는 다고 한다.

 

$.ajaxSetup() 안에 셋팅을 하고, $.ajax() 실행.

모든 함수를 사용하는 이후의 모든 ajax 호출은 $.ajaxSetup()의 다음 호출까지 개별 호출에 의해

재정의되지 않는 한 그대로 셋팅된 그대로 실행된다.

 

$.ajaxSetup({
	url : "ping.php"
});
$.ajax({
	//url not set here;
    //use ping.php
	data : {"name" : "Dan"}
});

 

 

example

$.ajaxSetup({
  url: "/xmlhttp/",
  global: false,
  type: "POST"
});
$.ajax({ data: myData });

 


참고사이트 

 

https://api.jquery.com/jquery.ajaxsetup/

 

jQuery.ajaxSetup() | jQuery API Documentation

Description: Set default values for future Ajax requests. Its use is not recommended. For details on the settings available for $.ajaxSetup(), see $.ajax(). All subsequent Ajax calls using any function will use the new settings, unless overridden by the in

api.jquery.com

 

728x90