-
Notifications
You must be signed in to change notification settings - Fork 48
/
jquery.2.sdocml
7357 lines (6752 loc) · 271 KB
/
jquery.2.sdocml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="UTF-8" ?>
<javascript>
<aliases>
<alias name="$" type="jQuery"/>
<alias type="Class<jQuery>" name="jQuery"/>
</aliases>
<class type="Offset" >
<properties>
<property type="Number" name="top" ></property>
<property type="Number" name="left" ></property>
</properties>
</class>
<class type="keyvalue" >
<properties>
<property type="String" name="name" ></property>
<property type="String" name="value" ></property>
</properties>
</class>
<class type="jQuerySetting" >
<properties>
<property type="String" name="accepts" ></property>
<property type="Boolean" name="async" ></property>
<property type="Function(jQuery.jqXHR,jQuerySetting)" name="beforeSend" ></property>
<property type="Boolean" name="cache" ></property>
<property type="Function(jQuery.jqXHR,String)" name="complete" ></property>
<property type="Object" name="contents" ></property>
<property type="String" name="contentType" ></property>
<property type="Object|Element" name="context" ></property>
<property type="Obejct" name="converters" ></property>
<property type="Obejct|String" name="data" ></property>
<property type="Function(String,String)" name="dataFilter" ></property>
<property type="Function(jQuery.jqXHR,String,String)" name="error" ></property>
<property type="Boolean" name="global" ></property>
<property type="Obejct" name="headers" ></property>
<property type="Boolean" name="ifModified" ></property>
<property type="Boolean" name="isLocal" ></property>
<property type="String" name="jsonp" ></property>
<property type="String|Function" name="jsonpCallback" ></property>
<property type="String" name="mimeType" ></property>
<property type="String" name="password" ></property>
<property type="Boolean" name="processData" ></property>
<property type="String" name="scriptCharset" ></property>
<property type="Object" name="xhrFields" ></property>
<property type="Object" name="statusCode" ></property>
<property type="Function(Object,String,jQuery.jqXHR)" name="success" ></property>
<property type="Number" name="timeout" ></property>
<property type="Boolean" name="traditional" ></property>
<property type="String" name="type" ></property>
<property type="String|URIString" name="url" ></property>
<property type="String" name="username" ></property>
<property type="Function" name="xhr" ></property>
</properties>
</class>
<class type="jQuery" superclass="Object">
<constructors>
<constructor>
<parameters>
<parameter name="selector" type="Selector|SelectorString" usage="required">
<description>A string containing a selector expression</description>
</parameter>
<parameter name="context" type="Element|jQuery" usage="optional">
<description>A DOM Element, Document, or jQuery to use as context</description>
</parameter>
<parameter name="element" type="Element" usage="required">
<description>A DOM element to wrap in a jQuery object.</description>
</parameter>
<parameter name="elementArray" type="Array" usage="required">
<description>An array containing a set of DOM elements to wrap in a jQuery object.</description>
</parameter>
<parameter name="jQuery object" type="Object" usage="required">
<description>An existing jQuery object to clone.</description>
</parameter>
</parameters>
<return-types>
<return-type type="jQuery"/>
<return-type type="jQuery.fn"/>
</return-types>
<description>Accepts a string containing a CSS selector which is then used to match a set of elements.</description>
<examples>
<example>
<p>Find all p elements that are children of a div element and apply a border to them.</p>
<p>
$("div > p").css("border", "1px solid gray");
</p>
</example>
<example>
<p>Find all inputs of type radio within the first form in the document.</p>
<p>$("input:radio", document.forms[0]);</p>
</example>
<example>
<p>Find all div elements within an XML document from an Ajax response.</p>
<p>$("div", xml.responseXML);</p>
</example>
<example>
<p>Set the background color of the page to black.</p>
<p>$(document.body).css( "background", "black" );</p>
</example>
<example>
<p>Hide all the input elements within a form.</p>
<p>$(myForm.elements).hide()</p>
</example>
</examples>
</constructor>
<constructor>
<parameters>
<parameter name="html" type="String|HTMLString" usage="required">
<description>A string of HTML to create on the fly. Note that this parses HTML, </description>
</parameter>
<parameter name="ownerDocument" type="Document" usage="optional">
<description>A document in which the new elements will be created</description>
</parameter>
<parameter name="html" type="String|HTMLString" usage="required">
<description>A string defining a single, standalone, HTML element (e.g. <div/> or <div></div>).</description>
</parameter>
<parameter name="props" type="Object" usage="required">
<description>An map of attributes, events, and methods to call on the newly-created element.</description>
</parameter>
</parameters>
<return-types>
<return-type type="jQuery"/>
<return-type type="jQuery.fn"/>
</return-types>
<description>Creates DOM elements on the fly from the provided string of raw HTML.</description>
<examples>
<example>
<p>Create a div element (and all of its contents) dynamically and append it to the body element. Internally, an element is created and its innerHTML property set to the given markup.</p>
<p>$("<div><p>Hello</p></div>").appendTo("body")</p>
</example>
<example>
<p>Create some DOM elements.</p>
<p>$("<div/>", {
"class": "test",
text: "Click me!",
click: function(){
$(this).toggleClass("test");
}
}).appendTo("body");</p>
</example>
</examples>
</constructor>
<constructor>
<parameters>
<parameter name="callback" type="Function" usage="required">
<description>The function to execute when the DOM is ready.</description>
</parameter>
</parameters>
<return-types>
<return-type type="jQuery"/>
<return-type type="jQuery.fn"/>
</return-types>
<description>Binds a function to be executed when the DOM has finished loading.</description>
<examples>
<example>
<p>Execute the function when the DOM is ready to be used.</p>
<p>$(function(){
// Document is ready
});
</p>
</example>
<example>
<p>Use both the shortcut for $(document).ready() and the argument to write failsafe jQuery code using the $ alias, without relying on the global alias.</p>
<p>jQuery(function($) {
// Your code using failsafe $ alias here...
});</p>
</example>
</examples>
</constructor>
</constructors>
<methods>
<method name="ajax" scope="static">
<parameters>
<parameter name="url" type="String|URIString|jQuerySetting" usage="required">
<description>A string containing the URL to which the request is sent.</description>
</parameter>
<parameter name="settings" type="Object" usage="optional">
<description>A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with </description>
</parameter>
</parameters>
<return-types>
<return-type type="jQuery.jqXHR"/>
</return-types>
<description>Perform an asynchronous HTTP (Ajax) request.</description>
<examples>
<example>
<p>Load and execute a JavaScript file.</p>
<p>$.ajax({
type: "GET",
url: "test.js",
dataType: "script"
});</p>
</example>
<example>
<p>Save some data to the server and notify the user once it's complete.</p>
<p>$.ajax({
type: "POST",
url: "some.php",
data: "name=John&location=Boston",
success: function(msg){
alert( "Data Saved: " + msg );
}
});</p>
</example>
<example>
<p>Retrieve the latest version of an HTML page.</p>
<p>$.ajax({
url: "test.html",
cache: false,
success: function(html){
$("#results").append(html);
}
});</p>
</example>
<example>
<p>Loads data synchronously. Blocks the browser while the requests is active.
It is better to block user interaction by other means when synchronization is
necessary.</p>
<p>var html = $.ajax({
url: "some.php",
async: false
}).responseText;</p>
</example>
<example>
<p>Sends an xml document as data to the server. By setting the processData
option to false, the automatic conversion of data to strings is prevented.</p>
<p>var xmlDocument = [create xml document];
$.ajax({
url: "page.php",
processData: false,
data: xmlDocument,
success: handleResponse
});</p>
</example>
<example>
<p>Sends an id as data to the server, save some data to the server and notify the user once it's complete. Note that this usage - returning the result of the call into a variable - requires a synchronous (blocking) request! (async:false)</p>
<p>var bodyContent = $.ajax({
url: "script.php",
global: false,
type: "POST",
data: {id : this.getAttribute('id')},
dataType: "html",
async:false,
success: function(msg){
alert(msg);
}
}
).responseText;</p>
</example>
</examples>
</method>
<method name="ajaxPrefilter" scope="static">
<parameters>
<parameter name="dataTypes" type="String" usage="optional">
<description>An optional string containing one or more space-separated dataTypes</description>
</parameter>
<parameter name="handler" type="Function(Object,Object,XMLHttpRequest)" usage="required">
<description>A handler to set default values for future Ajax requests.</description>
</parameter>
</parameters>
<return-types>
<return-type type="None"/>
</return-types>
<description>Handle custom Ajax options or modify existing options before each request is sent and before they are processed by </description>
</method>
<method name="ajaxSetup" scope="static">
<parameters>
<parameter name="options" type="Object" usage="required">
<description>A set of key/value pairs that configure the default Ajax request. All options are optional. </description>
</parameter>
</parameters>
<description>Set default values for future Ajax requests.</description>
<examples>
<example>
<p>Sets the defaults for Ajax requests to the url "/xmlhttp/", disables global handlers and uses POST instead of GET. The following Ajax requests then sends some data without having to set anything else.</p>
<p>$.ajaxSetup({
url: "/xmlhttp/",
global: false,
type: "POST"
});
$.ajax({ data: myData });</p>
</example>
</examples>
</method>
<method name="ajaxTransport" scope="static">
<return-types>
<return-type type="None"/>
</return-types>
<parameters>
<parameter name="dataType" type="String" usage=""/>
<parameter name="handler" type="Function(Object,Object,XMLHttpRequest)" usage=""/>
</parameters>
</method>
<method name="Callbacks" scope="static">
<return-types>
<return-type type="jQuery.Callbacks"/>
</return-types>
<parameters>
<parameter name="flags" type="String" usage=""/>
</parameters>
</method>
<method name="contains" scope="static">
<parameters>
<parameter name="container" type="Element" usage="required">
<description>The DOM element that may contain the other element.</description>
</parameter>
<parameter name="contained" type="Element" usage="required">
<description>The DOM element that may be contained by the other element.</description>
</parameter>
</parameters>
<return-types>
<return-type type="Boolean"/>
</return-types>
<description>Check to see if a DOM element is within another DOM element.</description>
<examples>
<example>
<p>Check if an element is inside another. Text and comment nodes are not supported.</p>
<p>jQuery.contains(document.documentElement, document.body); // true
jQuery.contains(document.body, document.documentElement); // false</p>
</example>
</examples>
</method>
<method name="data" scope="static">
<parameters>
<parameter name="element" type="Element" usage="required">
<description>The DOM element to associate with the data.</description>
</parameter>
<parameter name="key" type="String" usage="required">
<description>A string naming the piece of data to set.</description>
</parameter>
<parameter name="value" type="Object" usage="required">
<description>The new data value.</description>
</parameter>
</parameters>
<return-types>
<return-type type="Object"/>
</return-types>
<description>Store arbitrary data associated with the specified element. Returns the value that was set.</description>
<examples>
<example>
<p>Store then retrieve a value from the div element.</p>
<p>var div = $("div")[0];
jQuery.data(div, "test", { first: 16, last: "pizza!" });
$("span:first").text(jQuery.data(div, "test").first);
$("span:last").text(jQuery.data(div, "test").last);</p>
</example>
</examples>
</method>
<method name="Event" scope="static">
<return-types>
<return-type type="jQuery.Event"/>
</return-types>
<parameters>
<parameter name="type" type="Object" usage=""/>
<parameter name="props" type="Object" usage="optional"/>
</parameters>
</method>
<method name="Deferred" scope="static">
<parameters>
<parameter name="function" type="Function(jQuery.Deferred)" usage="optional">
<description>An optional function which is called just before the constructor returns and is passed the constructed deferred object as both the this object and as the first argument to the function.</description>
</parameter>
</parameters>
<return-types>
<return-type type="jQuery.Deferred"/>
</return-types>
<description>A chainable utility object that can register multiple callbacks into callback queues, invoke callback queues, and relay the success or failure state of any synchronous or asynchronous function.</description>
</method>
<method name="dequeue" scope="static">
<parameters>
<parameter name="element" type="Element" usage="required">
<description>A DOM element from which to remove and execute a queued function.</description>
</parameter>
<parameter name="queueName" type="String" usage="optional">
<description>A string containing the name of the queue. Defaults to </description>
</parameter>
</parameters>
<return-types>
<return-type type="jQuery.fn"/>
</return-types>
<description>Execute the next function on the queue for the matched element.</description>
<examples>
<example>
<p>Use dequeue to end a custom queue function which allows the queue to keep going.</p>
<p>$("button").click(function () {
$("div").animate({left:'+=200px'}, 2000);
$("div").animate({top:'0px'}, 600);
$("div").queue(function () {
$(this).toggleClass("red");
$.dequeue( this );
});
$("div").animate({left:'10px', top:'30px'}, 700);
});</p>
</example>
</examples>
</method>
<method name="each" scope="static">
<parameters>
<parameter name="collection" type="Object" usage="required">
<description>The object or array to iterate over.</description>
</parameter>
<parameter name="callback" type="Function" usage="required">
<description>The function that will be executed on every object.</description>
</parameter>
</parameters>
<return-types>
<return-type type="Object"/>
</return-types>
<description>A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties.</description>
<examples>
<example>
<p>Iterates through the array displaying each number as both a word and numeral</p>
<p>
var arr = [ "one", "two", "three", "four", "five" ];
var obj = { one:1, two:2, three:3, four:4, five:5 };
jQuery.each(arr, function() {
$("#" + this).text("Mine is " + this + ".");
return (this != "three"); // will stop running after "three"
});
jQuery.each(obj, function(i, val) {
$("#" + i).append(document.createTextNode(" - " + val));
});
</p>
</example>
<example>
<p>Iterates over items in an array, accessing both the current item and its index.</p>
<p>$.each( ['a','b','c'], function(i, l){
alert( "Index #" + i + ": " + l );
});</p>
</example>
<example>
<p>Iterates over the properties in an object, accessing both the current item and its key.</p>
<p>$.each( { name: "John", lang: "JS" }, function(k, v){
alert( "Key: " + k + ", Value: " + v );
});</p>
</example>
</examples>
</method>
<method name="extend" scope="static">
<parameters>
<parameter name="target" type="Object" usage="required">
<description> An object that will receive the new properties if additional objects are passed in or that will extend the jQuery namespace if it is the sole argument.</description>
</parameter>
<parameter name="object1" type="Object" usage="optional">
<description>An object containing additional properties to merge in.</description>
</parameter>
<parameter name="objectN" type="Object" usage="optional">
<description>Additional objects containing properties to merge in.</description>
</parameter>
<parameter name="deep" type="Boolean" usage="optional">
<description>If true, the merge becomes recursive (aka. deep copy).</description>
</parameter>
<parameter name="target" type="Object" usage="required">
<description>The object to extend. It will receive the new properties.</description>
</parameter>
<parameter name="object1" type="Object" usage="required">
<description>An object containing additional properties to merge in.</description>
</parameter>
<parameter name="objectN" type="Object" usage="optional">
<description>Additional objects containing properties to merge in.</description>
</parameter>
</parameters>
<return-types>
<return-type type="Object"/>
</return-types>
<description>Merge the contents of two or more objects together into the first object.</description>
<examples>
<example>
<p>Merge two objects, modifying the first.</p>
<p>
var object1 = {
apple: 0,
banana: {weight: 52, price: 100},
cherry: 97
};
var object2 = {
banana: {price: 200},
durian: 100
};
/* merge object2 into object1 */
$.extend(object1, object2);
var printObj = function(obj) {
var arr = [];
$.each(obj, function(key, val) {
var next = key + ": ";
next += $.isPlainObject(val) ? printObj(val) : val;
arr.push( next );
});
return "{ " + arr.join(", ") + " }";
};
$("#log").append( printObj(object1) );
</p>
</example>
<example>
<p>Merge two objects recursively, modifying the first.</p>
<p>
var object1 = {
apple: 0,
banana: {weight: 52, price: 100},
cherry: 97
};
var object2 = {
banana: {price: 200},
durian: 100
};
/* merge object2 into object1, recursively */
$.extend(true, object1, object2);
var printObj = function(obj) {
var arr = [];
$.each(obj, function(key, val) {
var next = key + ": ";
next += $.isPlainObject(val) ? printObj(val) : val;
arr.push( next );
});
return "{ " + arr.join(", ") + " }";
};
$("#log").append( printObj(object1) );
</p>
</example>
<example>
<p>Merge defaults and options, without modifying the defaults. This is a common plugin development pattern.</p>
<p>
var defaults = { validate: false, limit: 5, name: "foo" };
var options = { validate: true, name: "bar" };
/* merge defaults and options, without modifying defaults */
var settings = $.extend({}, defaults, options);
var printObj = function(obj) {
var arr = [];
$.each(obj, function(key, val) {
var next = key + ": ";
next += $.isPlainObject(val) ? printObj(val) : val;
arr.push( next );
});
return "{ " + arr.join(", ") + " }";
};
$("#log").append( "<div><b>settings -- </b>" + printObj(settings) + "</div>" );
$("#log").append( "<div><b>options -- </b>" + printObj(options) + "</div>" );
</p>
</example>
</examples>
</method>
<method name="fx" scope="static">
<return-types>
<return-type type="jQuery.fx"/>
</return-types>
<parameters>
<parameter name="elem" type="Element" usage=""/>
<parameter name="options" type="Object" usage=""/>
<parameter name="prop" type="String" usage=""/>
<parameter name="end" type="Number" usage="optional"/>
<parameter name="easing" type="Boolean" usage="optional"/>
</parameters>
</method>
<method name="get" scope="static">
<parameters>
<parameter name="url" type="String|URIString" usage="required">
<description>A string containing the URL to which the request is sent.</description>
</parameter>
<parameter name="data" type="Map|String" usage="optional">
<description>A map or string that is sent to the server with the request.</description>
</parameter>
<parameter name="success" type="Function(String,String,XMLHttpRequest)" usage="optional">
<description>A callback function that is executed if the request succeeds.</description>
</parameter>
<parameter name="dataType" type="String" usage="optional">
<description>The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html).</description>
</parameter>
</parameters>
<return-types>
<return-type type="jQuery.jqXHR"/>
</return-types>
<description>Load data from the server using a HTTP GET request.</description>
<examples>
<example>
<p>Request the test.php page, but ignore the return results.</p>
<p>$.get("test.php");</p>
</example>
<example>
<p>Request the test.php page and send some additional data along (while still ignoring the return results).</p>
<p>$.get("test.php", { name: "John", time: "2pm" } );</p>
</example>
<example>
<p>pass arrays of data to the server (while still ignoring the return results).</p>
<p>$.get("test.php", { 'choices[]': ["Jon", "Susan"]} );</p>
</example>
<example>
<p>Alert out the results from requesting test.php (HTML or XML, depending on what was returned).</p>
<p>$.get("test.php", function(data){
alert("Data Loaded: " + data);
});</p>
</example>
<example>
<p>Alert out the results from requesting test.cgi with an additional payload of data (HTML or XML, depending on what was returned).</p>
<p>$.get("test.cgi", { name: "John", time: "2pm" },
function(data){
alert("Data Loaded: " + data);
});</p>
</example>
<example>
<p> Gets the test.php page contents, which has been returned in json format (<?php echo json_encode(array("name"=>"John","time"=>"2pm")); ?>), and adds it to the page.</p>
<p>$.get("test.php",
function(data){
$('body').append("Name: " + data.name); // John
.append("Time: " + data.time); // 2pm
}, "json");</p>
</example>
</examples>
</method>
<method name="getJSON" scope="static">
<parameters>
<parameter name="url" type="String|URIString" usage="required">
<description>A string containing the URL to which the request is sent.</description>
</parameter>
<parameter name="data" type="Object" usage="optional">
<description>A map or string that is sent to the server with the request.</description>
</parameter>
<parameter name="success" type="Function(Object,String,XMLHttpRequest)" usage="optional">
<description>A callback function that is executed if the request succeeds.</description>
</parameter>
</parameters>
<return-types>
<return-type type="jQuery.jqXHR"/>
</return-types>
<description>Load JSON-encoded data from the server using a GET HTTP request.</description>
<examples>
<example>
<p>Loads the four most recent cat pictures from the Flickr JSONP API.</p>
<p>
$.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?",
{
tags: "cat",
tagmode: "any",
format: "json"
},
function(data) {
$.each(data.items, function(i,item){
$("<img/>").attr("src", item.media.m).appendTo("#images");
if ( i == 3 ) return false;
});
});</p>
</example>
<example>
<p>Load the JSON data from test.js and access a name from the returned JSON data.</p>
<p>$.getJSON("test.js", function(json) {
alert("JSON Data: " + json.users[3].name);
});</p>
</example>
<example>
<p>Load the JSON data from test.js, passing along additional data, and access a name from the returned JSON data.</p>
<p>$.getJSON("test.js", { name: "John", time: "2pm" }, function(json) {
alert("JSON Data: " + json.users[3].name);
});</p>
</example>
</examples>
</method>
<method name="getScript" scope="static">
<parameters>
<parameter name="url" type="String|URIString" usage="required">
<description>A string containing the URL to which the request is sent.</description>
</parameter>
<parameter name="success" type="Function(String,String,XMLHttpRequest)" usage="optional">
<description>A callback function that is executed if the request succeeds.</description>
</parameter>
</parameters>
<return-types>
<return-type type="jQuery.jqXHR"/>
</return-types>
<description>Load a JavaScript file from the server using a GET HTTP request, then execute it.</description>
<examples>
<example>
<p>Load the official jQuery Color Animation plugin dynamically and bind some color animations to occur once the new functionality is loaded.</p>
<p>
$.getScript("http://dev.jquery.com/view/trunk/plugins/color/jquery.color.js", function() {
$("#go").click(function(){
$(".block").animate( { backgroundColor: "pink" }, 1000)
.delay(500)
.animate( { backgroundColor: "blue" }, 1000);
});
});
</p>
</example>
</examples>
</method>
<method name="globalEval" scope="static">
<return-types>
<return-type type="None"/>
</return-types>
<parameters>
<parameter name="code" type="String" usage="required">
<description>The JavaScript code to execute.</description>
</parameter>
</parameters>
<description>Execute some JavaScript code globally.</description>
<examples>
<example>
<p>Execute a script in the global context.</p>
<p>function test(){
jQuery.globalEval("var newVar = true;")
}
test();
// newVar === true</p>
</example>
</examples>
</method>
<method name="grep" scope="static">
<parameters>
<parameter name="array" type="Array" usage="required">
<description>The array to search through.</description>
</parameter>
<parameter name="function" type="Function(Object,Number)" usage="required">
<description>The function to process each item against. The first argument to the function is the item, and the second argument is the index. The function should return a Boolean value. </description>
</parameter>
<parameter name="invert" type="Boolean" usage="optional">
<description>If "invert" is false, or not provided, then the function returns an array consisting of all elements for which "callback" returns true. If "invert" is true, then the function returns an array consisting of all elements for which "callback" returns false.</description>
</parameter>
</parameters>
<return-types>
<return-type type="Array"/>
</return-types>
<description>Finds the elements of an array which satisfy a filter function. The original array is not affected.</description>
<examples>
<example>
<p>Filters the original array of numbers leaving that are not 5 and have an index greater than 4. Then it removes all 9s.</p>
<p>
var arr = [ 1, 9, 3, 8, 6, 1, 5, 9, 4, 7, 3, 8, 6, 9, 1 ];
$("div").text(arr.join(", "));
arr = jQuery.grep(arr, function(n, i){
return (n != 5 && i > 4);
});
$("p").text(arr.join(", "));
arr = jQuery.grep(arr, function (a) { return a != 9; });
$("span").text(arr.join(", "));
</p>
</example>
<example>
<p>Filter an array of numbers to include only numbers bigger then zero.</p>
<p>$.grep( [0,1,2], function(n,i){
return n > 0;
});</p>
</example>
<example>
<p>Filter an array of numbers to include numbers that are not bigger than zero.</p>
<p>$.grep( [0,1,2], function(n,i){
return n > 0;
},true);</p>
</example>
</examples>
</method>
<method name="hasData" scope="static">
<parameters>
<parameter name="element" type="Element" usage="required">
<description>A DOM element to be checked for data.</description>
</parameter>
</parameters>
<return-types>
<return-type type="Boolean"/>
</return-types>
<description>Determine whether an element has any jQuery data associated with it.</description>
<examples>
<example>
<p>Set data on an element and see the results of hasData.</p>
<p>
$(function(){
var $p = jQuery("p"), p = $p[0];
$p.append(jQuery.hasData(p)+" "); /* false */
jQuery.data(p, "testing", 123);
$p.append(jQuery.hasData(p)+" "); /* true*/
jQuery.removeData(p, "testing");
$p.append(jQuery.hasData(p)+" "); /* false */
});
</p>
</example>
</examples>
</method>
<method name="holdReady" scope="static">
<parameters>
<parameter name="hold" type="Boolean" usage="required">
<description>Indicates whether the ready hold is being requested or released</description>
</parameter>
</parameters>
<return-types>
<return-type type="Boolean"/>
</return-types>
<description>Holds or releases the execution of jQuery's ready event.</description>
<examples>
<example>
<p>Delay the ready event until a custom plugin has loaded.</p>
<p>
$.holdReady(true);
$.getScript("myplugin.js", function() {
$.holdReady(false);
});
</p>
</example>
</examples>
</method>
<method name="inArray" scope="static">
<parameters>
<parameter name="value" type="Object" usage="required">
<description>The value to search for.</description>
</parameter>
<parameter name="array" type="Array" usage="required">
<description>An array through which to search.</description>
</parameter>
</parameters>
<return-types>
<return-type type="Number"/>
</return-types>
<description>Search for a specified value within an array and return its index (or -1 if not found).</description>
<examples>
<example>
<p>Report the index of some elements in the array.</p>
<p>var arr = [ 4, "Pete", 8, "John" ];
$("span:eq(0)").text(jQuery.inArray("John", arr));
$("span:eq(1)").text(jQuery.inArray(4, arr));
$("span:eq(2)").text(jQuery.inArray("Karl", arr));
</p>
</example>
</examples>
</method>
<method name="isArray" scope="static">
<parameters>
<parameter name="obj" type="Object" usage="required">
<description>Object to test whether or not it is an array.</description>
</parameter>
</parameters>
<return-types>
<return-type type="Boolean"/>
</return-types>
<description>Determine whether the argument is an array.</description>
<examples>
<example>
<p>Finds out if the parameter is an array.</p>
<p>$("b").append( "" + $.isArray([]) );</p>
</example>
</examples>
</method>
<method name="isEmptyObject" scope="static">
<parameters>
<parameter name="object" type="Object" usage="required">
<description>The object that will be checked to see if it's empty.</description>
</parameter>
</parameters>
<return-types>
<return-type type="Boolean"/>
</return-types>
<description>Check to see if an object is empty (contains no properties).</description>
<examples>
<example>
<p>Check an object to see if it's empty.</p>
<p>jQuery.isEmptyObject({}) // true
jQuery.isEmptyObject({ foo: "bar" }) // false</p>
</example>
</examples>
</method>
<method name="isFunction" scope="static">
<parameters>
<parameter name="obj" type="Object" usage="required">
<description>Object to test whether or not it is a function.</description>
</parameter>
</parameters>
<return-types>
<return-type type="Boolean"/>
</return-types>
<description>Determine if the argument passed is a Javascript function object. </description>
<examples>
<example>
<p>Test a few parameter examples.</p>
<p>
function stub() {
}
var objs = [
function () {},
{ x:15, y:20 },
null,
stub,
"function"
];
jQuery.each(objs, function (i) {
var isFunc = jQuery.isFunction(objs[i]);
$("span").eq(i).text(isFunc);
});
</p>
</example>
<example>
<p>Finds out if the parameter is a function.</p>
<p>$.isFunction(function(){});</p>
</example>
</examples>
</method>
<method name="isNumeric" scope="static">
<return-types>
<return-type type="Boolean"/>
</return-types>
<parameters>
<parameter name="obj" type="Object" usage=""/>
</parameters>
</method>
<method name="isPlainObject" scope="static">
<parameters>
<parameter name="object" type="Object" usage="required">
<description>The object that will be checked to see if it's a plain object.</description>
</parameter>
</parameters>
<return-types>
<return-type type="Boolean"/>
</return-types>
<description>Check to see if an object is a plain object (created using "{}" or "new Object").</description>
<examples>
<example>
<p>Check an object to see if it's a plain object.</p>
<p>jQuery.isPlainObject({}) // true
jQuery.isPlainObject("test") // false</p>
</example>
</examples>
</method>
<method name="isWindow" scope="static">
<parameters>
<parameter name="obj" type="Object" usage="required">
<description>Object to test whether or not it is a window.</description>
</parameter>
</parameters>
<return-types>
<return-type type="Boolean"/>
</return-types>
<description>Determine whether the argument is a window.</description>
<examples>
<example>
<p>Finds out if the parameter is a window.</p>
<p>$("b").append( "" + $.isWindow(window) );</p>
</example>
</examples>