$.ajax
함수를 사용하여 모든 기본값을 가져올 수 있습니까? 그들은 jQuery를 워드 프로세서에 나와있는
{
global:true,
headers:{},
ifModified:false,
type:"GET",
url:"the current page url",
etc....
}
$.ajax
함수를 사용하여 모든 기본값을 가져올 수 있습니까? 그들은 jQuery를 워드 프로세서에 나와있는
{
global:true,
headers:{},
ifModified:false,
type:"GET",
url:"the current page url",
etc....
}
을, 나는 (현재) 기본값은 믿는다 jQuery.ajaxSettings
에서 찾을 수 있습니다. 물론 $.ajaxSettings
도 있습니다. 그래서 당신이 그들을 변경하지 않은 경우, 당신은 그들을 거기에서 얻을 수 있어야합니다. 당신이 경우이 $.ajaxSetup
유틸리티 메소드를 사용하여 예를 들어,이를 변경하는 것이
주, 당신은 당신이 만든 새 기본값을 얻을 것이다, jQuery 라이브러리에서없는 고유 한 것.
ajaxSettings: {
url: ajaxLocation,
isLocal: rlocalProtocol.test(ajaxLocParts[ 1 ]),
global: true,
type: "GET",
contentType: "application/x-www-form-urlencoded",
processData: true,
async: true,
/*
timeout: 0,
data: null,
dataType: null,
username: null,
password: null,
cache: null,
traditional: false,
headers: {},
*/
accepts: {
xml: "application/xml, text/xml",
html: "text/html",
text: "text/plain",
json: "application/json, text/javascript",
"*": "*/*"
},
contents: {
xml: /xml/,
html: /html/,
json: /json/
},
responseFields: {
xml: "responseXML",
text: "responseText"
},
// List of data converters
// 1) key format is "source_type destination_type" (a single space in-between)
// 2) the catchall symbol "*" can be used for source_type
converters: {
// Convert anything to text
"* text": window.String,
// Text to html (true = no transformation)
"text html": true,
// Evaluate text as a json expression
"text json": jQuery.parseJSON,
// Parse text as xml
"text xml": jQuery.parseXML
}
},
하지만'$ .ajaxSetup()'를 사용하여 기본값을 변경할 수 있습니다
또한 소스 코드를보고, 기본값은 다음과 같습니다 보인다. –
예, 그렇지만 @mu와 (과) 같이'$ .ajaxSetup'이 그들을 – locrizak
(으)로 덮어 쓸 수 있기 때문에 대상을 하드 코딩하지 않으려 고합니다. 감사합니다. – locrizak
@locrizak : 이것이 문서화되지 않았 음을 기억하십시오. 반드시 미래의 증거는 아닙니다. –
사실,하지만 오히려 jquery 라이브러리에서 다른 오브젝트로 다시 작성하는 대신 뭔가를 사용합니다. – locrizak