1 | define([
|
2 | "./core",
|
3 | "./var/rnotwhite",
|
4 | "./ajax/var/nonce",
|
5 | "./ajax/var/rquery",
|
6 | "./core/init",
|
7 | "./ajax/parseJSON",
|
8 | "./ajax/parseXML",
|
9 | "./deferred"
|
10 | ], function( jQuery, rnotwhite, nonce, rquery ) {
|
11 |
|
12 | var
|
13 |
|
14 | ajaxLocParts,
|
15 | ajaxLocation,
|
16 |
|
17 | rhash = /#.*$/,
|
18 | rts = /([?&])_=[^&]*/,
|
19 | rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
|
20 |
|
21 | rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
|
22 | rnoContent = /^(?:GET|HEAD)$/,
|
23 | rprotocol = /^\/\//,
|
24 | rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
|
25 |
|
26 | |
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | prefilters = {},
|
36 |
|
37 | |
38 |
|
39 |
|
40 |
|
41 |
|
42 | transports = {},
|
43 |
|
44 |
|
45 | allTypes = "*/".concat("*");
|
46 |
|
47 |
|
48 |
|
49 | try {
|
50 | ajaxLocation = location.href;
|
51 | } catch( e ) {
|
52 |
|
53 |
|
54 | ajaxLocation = document.createElement( "a" );
|
55 | ajaxLocation.href = "";
|
56 | ajaxLocation = ajaxLocation.href;
|
57 | }
|
58 |
|
59 |
|
60 | ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
|
61 |
|
62 |
|
63 | function addToPrefiltersOrTransports( structure ) {
|
64 |
|
65 |
|
66 | return function( dataTypeExpression, func ) {
|
67 |
|
68 | if ( typeof dataTypeExpression !== "string" ) {
|
69 | func = dataTypeExpression;
|
70 | dataTypeExpression = "*";
|
71 | }
|
72 |
|
73 | var dataType,
|
74 | i = 0,
|
75 | dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
|
76 |
|
77 | if ( jQuery.isFunction( func ) ) {
|
78 |
|
79 | while ( (dataType = dataTypes[i++]) ) {
|
80 |
|
81 | if ( dataType[0] === "+" ) {
|
82 | dataType = dataType.slice( 1 ) || "*";
|
83 | (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
|
84 |
|
85 |
|
86 | } else {
|
87 | (structure[ dataType ] = structure[ dataType ] || []).push( func );
|
88 | }
|
89 | }
|
90 | }
|
91 | };
|
92 | }
|
93 |
|
94 |
|
95 | function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
|
96 |
|
97 | var inspected = {},
|
98 | seekingTransport = ( structure === transports );
|
99 |
|
100 | function inspect( dataType ) {
|
101 | var selected;
|
102 | inspected[ dataType ] = true;
|
103 | jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
|
104 | var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
|
105 | if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
|
106 | options.dataTypes.unshift( dataTypeOrTransport );
|
107 | inspect( dataTypeOrTransport );
|
108 | return false;
|
109 | } else if ( seekingTransport ) {
|
110 | return !( selected = dataTypeOrTransport );
|
111 | }
|
112 | });
|
113 | return selected;
|
114 | }
|
115 |
|
116 | return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
|
117 | }
|
118 |
|
119 |
|
120 |
|
121 |
|
122 | function ajaxExtend( target, src ) {
|
123 | var key, deep,
|
124 | flatOptions = jQuery.ajaxSettings.flatOptions || {};
|
125 |
|
126 | for ( key in src ) {
|
127 | if ( src[ key ] !== undefined ) {
|
128 | ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
|
129 | }
|
130 | }
|
131 | if ( deep ) {
|
132 | jQuery.extend( true, target, deep );
|
133 | }
|
134 |
|
135 | return target;
|
136 | }
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 | function ajaxHandleResponses( s, jqXHR, responses ) {
|
143 |
|
144 | var ct, type, finalDataType, firstDataType,
|
145 | contents = s.contents,
|
146 | dataTypes = s.dataTypes;
|
147 |
|
148 |
|
149 | while ( dataTypes[ 0 ] === "*" ) {
|
150 | dataTypes.shift();
|
151 | if ( ct === undefined ) {
|
152 | ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
|
153 | }
|
154 | }
|
155 |
|
156 |
|
157 | if ( ct ) {
|
158 | for ( type in contents ) {
|
159 | if ( contents[ type ] && contents[ type ].test( ct ) ) {
|
160 | dataTypes.unshift( type );
|
161 | break;
|
162 | }
|
163 | }
|
164 | }
|
165 |
|
166 |
|
167 | if ( dataTypes[ 0 ] in responses ) {
|
168 | finalDataType = dataTypes[ 0 ];
|
169 | } else {
|
170 |
|
171 | for ( type in responses ) {
|
172 | if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
|
173 | finalDataType = type;
|
174 | break;
|
175 | }
|
176 | if ( !firstDataType ) {
|
177 | firstDataType = type;
|
178 | }
|
179 | }
|
180 |
|
181 | finalDataType = finalDataType || firstDataType;
|
182 | }
|
183 |
|
184 |
|
185 |
|
186 |
|
187 | if ( finalDataType ) {
|
188 | if ( finalDataType !== dataTypes[ 0 ] ) {
|
189 | dataTypes.unshift( finalDataType );
|
190 | }
|
191 | return responses[ finalDataType ];
|
192 | }
|
193 | }
|
194 |
|
195 |
|
196 |
|
197 |
|
198 | function ajaxConvert( s, response, jqXHR, isSuccess ) {
|
199 | var conv2, current, conv, tmp, prev,
|
200 | converters = {},
|
201 |
|
202 | dataTypes = s.dataTypes.slice();
|
203 |
|
204 |
|
205 | if ( dataTypes[ 1 ] ) {
|
206 | for ( conv in s.converters ) {
|
207 | converters[ conv.toLowerCase() ] = s.converters[ conv ];
|
208 | }
|
209 | }
|
210 |
|
211 | current = dataTypes.shift();
|
212 |
|
213 |
|
214 | while ( current ) {
|
215 |
|
216 | if ( s.responseFields[ current ] ) {
|
217 | jqXHR[ s.responseFields[ current ] ] = response;
|
218 | }
|
219 |
|
220 |
|
221 | if ( !prev && isSuccess && s.dataFilter ) {
|
222 | response = s.dataFilter( response, s.dataType );
|
223 | }
|
224 |
|
225 | prev = current;
|
226 | current = dataTypes.shift();
|
227 |
|
228 | if ( current ) {
|
229 |
|
230 |
|
231 | if ( current === "*" ) {
|
232 |
|
233 | current = prev;
|
234 |
|
235 |
|
236 | } else if ( prev !== "*" && prev !== current ) {
|
237 |
|
238 |
|
239 | conv = converters[ prev + " " + current ] || converters[ "* " + current ];
|
240 |
|
241 |
|
242 | if ( !conv ) {
|
243 | for ( conv2 in converters ) {
|
244 |
|
245 |
|
246 | tmp = conv2.split( " " );
|
247 | if ( tmp[ 1 ] === current ) {
|
248 |
|
249 |
|
250 | conv = converters[ prev + " " + tmp[ 0 ] ] ||
|
251 | converters[ "* " + tmp[ 0 ] ];
|
252 | if ( conv ) {
|
253 |
|
254 | if ( conv === true ) {
|
255 | conv = converters[ conv2 ];
|
256 |
|
257 |
|
258 | } else if ( converters[ conv2 ] !== true ) {
|
259 | current = tmp[ 0 ];
|
260 | dataTypes.unshift( tmp[ 1 ] );
|
261 | }
|
262 | break;
|
263 | }
|
264 | }
|
265 | }
|
266 | }
|
267 |
|
268 |
|
269 | if ( conv !== true ) {
|
270 |
|
271 |
|
272 | if ( conv && s[ "throws" ] ) {
|
273 | response = conv( response );
|
274 | } else {
|
275 | try {
|
276 | response = conv( response );
|
277 | } catch ( e ) {
|
278 | return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
|
279 | }
|
280 | }
|
281 | }
|
282 | }
|
283 | }
|
284 | }
|
285 |
|
286 | return { state: "success", data: response };
|
287 | }
|
288 |
|
289 | jQuery.extend({
|
290 |
|
291 |
|
292 | active: 0,
|
293 |
|
294 |
|
295 | lastModified: {},
|
296 | etag: {},
|
297 |
|
298 | ajaxSettings: {
|
299 | url: ajaxLocation,
|
300 | type: "GET",
|
301 | isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
|
302 | global: true,
|
303 | processData: true,
|
304 | async: true,
|
305 | contentType: "application/x-www-form-urlencoded; charset=UTF-8",
|
306 | |
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 | accepts: {
|
319 | "*": allTypes,
|
320 | text: "text/plain",
|
321 | html: "text/html",
|
322 | xml: "application/xml, text/xml",
|
323 | json: "application/json, text/javascript"
|
324 | },
|
325 |
|
326 | contents: {
|
327 | xml: /xml/,
|
328 | html: /html/,
|
329 | json: /json/
|
330 | },
|
331 |
|
332 | responseFields: {
|
333 | xml: "responseXML",
|
334 | text: "responseText",
|
335 | json: "responseJSON"
|
336 | },
|
337 |
|
338 |
|
339 |
|
340 | converters: {
|
341 |
|
342 |
|
343 | "* text": String,
|
344 |
|
345 |
|
346 | "text html": true,
|
347 |
|
348 |
|
349 | "text json": jQuery.parseJSON,
|
350 |
|
351 |
|
352 | "text xml": jQuery.parseXML
|
353 | },
|
354 |
|
355 |
|
356 |
|
357 |
|
358 |
|
359 | flatOptions: {
|
360 | url: true,
|
361 | context: true
|
362 | }
|
363 | },
|
364 |
|
365 |
|
366 |
|
367 |
|
368 | ajaxSetup: function( target, settings ) {
|
369 | return settings ?
|
370 |
|
371 |
|
372 | ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
|
373 |
|
374 |
|
375 | ajaxExtend( jQuery.ajaxSettings, target );
|
376 | },
|
377 |
|
378 | ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
|
379 | ajaxTransport: addToPrefiltersOrTransports( transports ),
|
380 |
|
381 |
|
382 | ajax: function( url, options ) {
|
383 |
|
384 |
|
385 | if ( typeof url === "object" ) {
|
386 | options = url;
|
387 | url = undefined;
|
388 | }
|
389 |
|
390 |
|
391 | options = options || {};
|
392 |
|
393 | var transport,
|
394 |
|
395 | cacheURL,
|
396 |
|
397 | responseHeadersString,
|
398 | responseHeaders,
|
399 |
|
400 | timeoutTimer,
|
401 |
|
402 | parts,
|
403 |
|
404 | fireGlobals,
|
405 |
|
406 | i,
|
407 |
|
408 | s = jQuery.ajaxSetup( {}, options ),
|
409 |
|
410 | callbackContext = s.context || s,
|
411 |
|
412 | globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
|
413 | jQuery( callbackContext ) :
|
414 | jQuery.event,
|
415 |
|
416 | deferred = jQuery.Deferred(),
|
417 | completeDeferred = jQuery.Callbacks("once memory"),
|
418 |
|
419 | statusCode = s.statusCode || {},
|
420 |
|
421 | requestHeaders = {},
|
422 | requestHeadersNames = {},
|
423 |
|
424 | state = 0,
|
425 |
|
426 | strAbort = "canceled",
|
427 |
|
428 | jqXHR = {
|
429 | readyState: 0,
|
430 |
|
431 |
|
432 | getResponseHeader: function( key ) {
|
433 | var match;
|
434 | if ( state === 2 ) {
|
435 | if ( !responseHeaders ) {
|
436 | responseHeaders = {};
|
437 | while ( (match = rheaders.exec( responseHeadersString )) ) {
|
438 | responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
|
439 | }
|
440 | }
|
441 | match = responseHeaders[ key.toLowerCase() ];
|
442 | }
|
443 | return match == null ? null : match;
|
444 | },
|
445 |
|
446 |
|
447 | getAllResponseHeaders: function() {
|
448 | return state === 2 ? responseHeadersString : null;
|
449 | },
|
450 |
|
451 |
|
452 | setRequestHeader: function( name, value ) {
|
453 | var lname = name.toLowerCase();
|
454 | if ( !state ) {
|
455 | name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
|
456 | requestHeaders[ name ] = value;
|
457 | }
|
458 | return this;
|
459 | },
|
460 |
|
461 |
|
462 | overrideMimeType: function( type ) {
|
463 | if ( !state ) {
|
464 | s.mimeType = type;
|
465 | }
|
466 | return this;
|
467 | },
|
468 |
|
469 |
|
470 | statusCode: function( map ) {
|
471 | var code;
|
472 | if ( map ) {
|
473 | if ( state < 2 ) {
|
474 | for ( code in map ) {
|
475 |
|
476 | statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
|
477 | }
|
478 | } else {
|
479 |
|
480 | jqXHR.always( map[ jqXHR.status ] );
|
481 | }
|
482 | }
|
483 | return this;
|
484 | },
|
485 |
|
486 |
|
487 | abort: function( statusText ) {
|
488 | var finalText = statusText || strAbort;
|
489 | if ( transport ) {
|
490 | transport.abort( finalText );
|
491 | }
|
492 | done( 0, finalText );
|
493 | return this;
|
494 | }
|
495 | };
|
496 |
|
497 |
|
498 | deferred.promise( jqXHR ).complete = completeDeferred.add;
|
499 | jqXHR.success = jqXHR.done;
|
500 | jqXHR.error = jqXHR.fail;
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 | s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" )
|
507 | .replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
|
508 |
|
509 |
|
510 | s.type = options.method || options.type || s.method || s.type;
|
511 |
|
512 |
|
513 | s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
|
514 |
|
515 |
|
516 | if ( s.crossDomain == null ) {
|
517 | parts = rurl.exec( s.url.toLowerCase() );
|
518 | s.crossDomain = !!( parts &&
|
519 | ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
|
520 | ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
|
521 | ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
|
522 | );
|
523 | }
|
524 |
|
525 |
|
526 | if ( s.data && s.processData && typeof s.data !== "string" ) {
|
527 | s.data = jQuery.param( s.data, s.traditional );
|
528 | }
|
529 |
|
530 |
|
531 | inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
|
532 |
|
533 |
|
534 | if ( state === 2 ) {
|
535 | return jqXHR;
|
536 | }
|
537 |
|
538 |
|
539 | fireGlobals = s.global;
|
540 |
|
541 |
|
542 | if ( fireGlobals && jQuery.active++ === 0 ) {
|
543 | jQuery.event.trigger("ajaxStart");
|
544 | }
|
545 |
|
546 |
|
547 | s.type = s.type.toUpperCase();
|
548 |
|
549 |
|
550 | s.hasContent = !rnoContent.test( s.type );
|
551 |
|
552 |
|
553 |
|
554 | cacheURL = s.url;
|
555 |
|
556 |
|
557 | if ( !s.hasContent ) {
|
558 |
|
559 |
|
560 | if ( s.data ) {
|
561 | cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
|
562 |
|
563 | delete s.data;
|
564 | }
|
565 |
|
566 |
|
567 | if ( s.cache === false ) {
|
568 | s.url = rts.test( cacheURL ) ?
|
569 |
|
570 |
|
571 | cacheURL.replace( rts, "$1_=" + nonce++ ) :
|
572 |
|
573 |
|
574 | cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
|
575 | }
|
576 | }
|
577 |
|
578 |
|
579 | if ( s.ifModified ) {
|
580 | if ( jQuery.lastModified[ cacheURL ] ) {
|
581 | jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
|
582 | }
|
583 | if ( jQuery.etag[ cacheURL ] ) {
|
584 | jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
|
585 | }
|
586 | }
|
587 |
|
588 |
|
589 | if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
|
590 | jqXHR.setRequestHeader( "Content-Type", s.contentType );
|
591 | }
|
592 |
|
593 |
|
594 | jqXHR.setRequestHeader(
|
595 | "Accept",
|
596 | s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
|
597 | s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
|
598 | s.accepts[ "*" ]
|
599 | );
|
600 |
|
601 |
|
602 | for ( i in s.headers ) {
|
603 | jqXHR.setRequestHeader( i, s.headers[ i ] );
|
604 | }
|
605 |
|
606 |
|
607 | if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
|
608 |
|
609 | return jqXHR.abort();
|
610 | }
|
611 |
|
612 |
|
613 | strAbort = "abort";
|
614 |
|
615 |
|
616 | for ( i in { success: 1, error: 1, complete: 1 } ) {
|
617 | jqXHR[ i ]( s[ i ] );
|
618 | }
|
619 |
|
620 |
|
621 | transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
|
622 |
|
623 |
|
624 | if ( !transport ) {
|
625 | done( -1, "No Transport" );
|
626 | } else {
|
627 | jqXHR.readyState = 1;
|
628 |
|
629 |
|
630 | if ( fireGlobals ) {
|
631 | globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
|
632 | }
|
633 |
|
634 | if ( s.async && s.timeout > 0 ) {
|
635 | timeoutTimer = setTimeout(function() {
|
636 | jqXHR.abort("timeout");
|
637 | }, s.timeout );
|
638 | }
|
639 |
|
640 | try {
|
641 | state = 1;
|
642 | transport.send( requestHeaders, done );
|
643 | } catch ( e ) {
|
644 |
|
645 | if ( state < 2 ) {
|
646 | done( -1, e );
|
647 |
|
648 | } else {
|
649 | throw e;
|
650 | }
|
651 | }
|
652 | }
|
653 |
|
654 |
|
655 | function done( status, nativeStatusText, responses, headers ) {
|
656 | var isSuccess, success, error, response, modified,
|
657 | statusText = nativeStatusText;
|
658 |
|
659 |
|
660 | if ( state === 2 ) {
|
661 | return;
|
662 | }
|
663 |
|
664 |
|
665 | state = 2;
|
666 |
|
667 |
|
668 | if ( timeoutTimer ) {
|
669 | clearTimeout( timeoutTimer );
|
670 | }
|
671 |
|
672 |
|
673 |
|
674 | transport = undefined;
|
675 |
|
676 |
|
677 | responseHeadersString = headers || "";
|
678 |
|
679 |
|
680 | jqXHR.readyState = status > 0 ? 4 : 0;
|
681 |
|
682 |
|
683 | isSuccess = status >= 200 && status < 300 || status === 304;
|
684 |
|
685 |
|
686 | if ( responses ) {
|
687 | response = ajaxHandleResponses( s, jqXHR, responses );
|
688 | }
|
689 |
|
690 |
|
691 | response = ajaxConvert( s, response, jqXHR, isSuccess );
|
692 |
|
693 |
|
694 | if ( isSuccess ) {
|
695 |
|
696 |
|
697 | if ( s.ifModified ) {
|
698 | modified = jqXHR.getResponseHeader("Last-Modified");
|
699 | if ( modified ) {
|
700 | jQuery.lastModified[ cacheURL ] = modified;
|
701 | }
|
702 | modified = jqXHR.getResponseHeader("etag");
|
703 | if ( modified ) {
|
704 | jQuery.etag[ cacheURL ] = modified;
|
705 | }
|
706 | }
|
707 |
|
708 |
|
709 | if ( status === 204 || s.type === "HEAD" ) {
|
710 | statusText = "nocontent";
|
711 |
|
712 |
|
713 | } else if ( status === 304 ) {
|
714 | statusText = "notmodified";
|
715 |
|
716 |
|
717 | } else {
|
718 | statusText = response.state;
|
719 | success = response.data;
|
720 | error = response.error;
|
721 | isSuccess = !error;
|
722 | }
|
723 | } else {
|
724 |
|
725 |
|
726 | error = statusText;
|
727 | if ( status || !statusText ) {
|
728 | statusText = "error";
|
729 | if ( status < 0 ) {
|
730 | status = 0;
|
731 | }
|
732 | }
|
733 | }
|
734 |
|
735 |
|
736 | jqXHR.status = status;
|
737 | jqXHR.statusText = ( nativeStatusText || statusText ) + "";
|
738 |
|
739 |
|
740 | if ( isSuccess ) {
|
741 | deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
|
742 | } else {
|
743 | deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
|
744 | }
|
745 |
|
746 |
|
747 | jqXHR.statusCode( statusCode );
|
748 | statusCode = undefined;
|
749 |
|
750 | if ( fireGlobals ) {
|
751 | globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
|
752 | [ jqXHR, s, isSuccess ? success : error ] );
|
753 | }
|
754 |
|
755 |
|
756 | completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
|
757 |
|
758 | if ( fireGlobals ) {
|
759 | globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
|
760 |
|
761 | if ( !( --jQuery.active ) ) {
|
762 | jQuery.event.trigger("ajaxStop");
|
763 | }
|
764 | }
|
765 | }
|
766 |
|
767 | return jqXHR;
|
768 | },
|
769 |
|
770 | getJSON: function( url, data, callback ) {
|
771 | return jQuery.get( url, data, callback, "json" );
|
772 | },
|
773 |
|
774 | getScript: function( url, callback ) {
|
775 | return jQuery.get( url, undefined, callback, "script" );
|
776 | }
|
777 | });
|
778 |
|
779 | jQuery.each( [ "get", "post" ], function( i, method ) {
|
780 | jQuery[ method ] = function( url, data, callback, type ) {
|
781 |
|
782 | if ( jQuery.isFunction( data ) ) {
|
783 | type = type || callback;
|
784 | callback = data;
|
785 | data = undefined;
|
786 | }
|
787 |
|
788 | return jQuery.ajax({
|
789 | url: url,
|
790 | type: method,
|
791 | dataType: type,
|
792 | data: data,
|
793 | success: callback
|
794 | });
|
795 | };
|
796 | });
|
797 |
|
798 |
|
799 | jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
|
800 | jQuery.fn[ type ] = function( fn ) {
|
801 | return this.on( type, fn );
|
802 | };
|
803 | });
|
804 |
|
805 | return jQuery;
|
806 | });
|