Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
8c9d3272
Commit
8c9d3272
authored
Dec 28, 2010
by
jaubourg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed several ajaxSettings options. Removed cors test, fixed failing cors test.
parent
97b32d78
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
59 deletions
+27
-59
ajax.js
src/ajax.js
+11
-11
jsonp.js
src/transports/jsonp.js
+1
-1
script.js
src/transports/script.js
+2
-2
ajax.js
test/unit/ajax.js
+13
-45
No files found.
src/ajax.js
View file @
8c9d3272
...
...
@@ -183,7 +183,7 @@ jQuery.extend({
"*"
:
"*/*"
},
autoDataType
:
{
contents
:
{
xml
:
/xml/
,
html
:
/html/
,
json
:
/json/
...
...
@@ -208,7 +208,7 @@ jQuery.extend({
// 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
dataC
onverters
:
{
c
onverters
:
{
// Convert anything to text
"* text"
:
window
.
String
,
...
...
@@ -398,7 +398,7 @@ jQuery.extend({
oneConv
,
convertion
,
dataTypes
=
s
.
dataTypes
,
dataConverters
=
s
.
dataC
onverters
,
converters
=
s
.
c
onverters
,
responses
=
{
"xml"
:
"XML"
,
"text"
:
"Text"
...
...
@@ -420,14 +420,14 @@ jQuery.extend({
if
(
prev
!==
"*"
&&
current
!==
"*"
&&
prev
!==
current
)
{
oneConv
=
conv1
=
dataC
onverters
[
(
conversion
=
prev
+
" "
+
current
)
]
||
dataC
onverters
[
"* "
+
current
];
c
onverters
[
(
conversion
=
prev
+
" "
+
current
)
]
||
c
onverters
[
"* "
+
current
];
if
(
oneConv
!==
true
)
{
if
(
!
oneConv
&&
prev
!==
"text"
&&
current
!==
"text"
)
{
conv1
=
dataConverters
[
prev
+
" text"
]
||
dataC
onverters
[
"* text"
];
conv2
=
dataC
onverters
[
"text "
+
current
];
conv1
=
converters
[
prev
+
" text"
]
||
c
onverters
[
"* text"
];
conv2
=
c
onverters
[
"text "
+
current
];
}
if
(
oneConv
||
conv1
&&
conv2
)
{
...
...
@@ -841,7 +841,7 @@ jQuery.each( [ "prefilter" , "transport" ] , function( _ , name ) {
// (for those transports that can give text or xml responses)
function
determineDataType
(
s
,
ct
,
text
,
xml
)
{
var
autoDataType
=
s
.
autoDataType
,
var
contents
=
s
.
contents
,
type
,
regexp
,
dataTypes
=
s
.
dataTypes
,
...
...
@@ -851,8 +851,8 @@ function determineDataType( s , ct , text , xml ) {
// Auto (xml, json, script or text determined given headers)
if
(
transportDataType
===
"*"
)
{
for
(
type
in
autoDataType
)
{
if
(
(
regexp
=
autoDataType
[
type
]
)
&&
regexp
.
test
(
ct
)
)
{
for
(
type
in
contents
)
{
if
(
(
regexp
=
contents
[
type
]
)
&&
regexp
.
test
(
ct
)
)
{
transportDataType
=
dataTypes
[
0
]
=
type
;
break
;
}
...
...
@@ -871,7 +871,7 @@ function determineDataType( s , ct , text , xml ) {
response
=
text
;
// If it's not really text, defer to
dataC
onverters
// If it's not really text, defer to
c
onverters
if
(
transportDataType
!==
"text"
)
{
dataTypes
.
unshift
(
"text"
);
}
...
...
src/transports/jsonp.js
View file @
8c9d3272
...
...
@@ -70,7 +70,7 @@ jQuery.ajax.prefilter("json jsonp", function(s) {
},
s
.
complete
];
// Use data converter to retrieve json after script execution
s
.
dataC
onverters
[
"script json"
]
=
function
()
{
s
.
c
onverters
[
"script json"
]
=
function
()
{
if
(
!
responseContainer
)
{
jQuery
.
error
(
jsonpCallback
+
" was not called"
);
}
...
...
src/transports/script.js
View file @
8c9d3272
...
...
@@ -7,11 +7,11 @@ jQuery.extend( true, jQuery.ajaxSettings , {
script
:
"text/javascript, application/javascript"
},
autoDataType
:
{
contents
:
{
script
:
/javascript/
},
dataC
onverters
:
{
c
onverters
:
{
"text script"
:
jQuery
.
globalEval
}
}
);
...
...
test/unit/ajax.js
View file @
8c9d3272
...
...
@@ -70,44 +70,6 @@ test("jQuery.ajax() - success callbacks - (url, options) syntax", function() {
},
13
);
});
test
(
"jQuery.ajax() - success/error callbacks (remote)"
,
function
()
{
var
supports
=
jQuery
.
support
.
cors
;
expect
(
supports
?
9
:
4
);
jQuery
.
ajaxSetup
({
timeout
:
0
});
stop
();
setTimeout
(
function
(){
jQuery
(
'#foo'
).
ajaxStart
(
function
(){
ok
(
true
,
"ajaxStart"
);
}).
ajaxStop
(
function
(){
ok
(
true
,
"ajaxStop"
);
start
();
}).
ajaxSend
(
function
(){
ok
(
supports
,
"ajaxSend"
);
}).
ajaxComplete
(
function
(){
ok
(
true
,
"ajaxComplete"
);
}).
ajaxError
(
function
(){
ok
(
!
supports
,
"ajaxError"
);
}).
ajaxSuccess
(
function
(){
ok
(
supports
,
"ajaxSuccess"
);
});
jQuery
.
ajax
({
// JULIAN TODO: Get an url especially for jQuery
url
:
"http://rockstarapps.com/test.php"
,
dataType
:
"text"
,
beforeSend
:
function
(){
ok
(
supports
,
"beforeSend"
);
},
success
:
function
(
val
){
ok
(
supports
,
"success"
);
ok
(
supports
&&
val
.
length
,
"data received"
);
},
error
:
function
(
_
,
a
,
b
){
ok
(
false
,
"error"
);
},
complete
:
function
(){
ok
(
supports
,
"complete"
);
}
});
},
13
);
});
test
(
"jQuery.ajax() - success callbacks (late binding)"
,
function
()
{
expect
(
8
);
...
...
@@ -1328,12 +1290,12 @@ test("jQuery.ajax() - json by content-type disabled with options", function() {
jQuery
.
ajax
({
url
:
url
(
"data/json.php"
),
data
:
{
header
:
"json"
,
json
:
"array"
},
autoDataType
:
{
contents
:
{
json
:
false
},
success
:
function
(
text
)
{
equals
(
typeof
text
,
"string"
,
"json wasn't auto-determined"
);
var
json
=
this
.
dataConverters
[
"text json"
]
(
text
);
var
json
=
jQuery
.
parseJSON
(
text
);
ok
(
json
.
length
>=
2
,
"Check length"
);
equals
(
json
[
0
].
name
,
'John'
,
'Check JSON: first, name'
);
equals
(
json
[
0
].
age
,
21
,
'Check JSON: first, age'
);
...
...
@@ -1677,19 +1639,25 @@ test("jQuery ajax - failing cross-domain", function() {
var
i
=
2
;
jQuery
.
ajax
({
url
:
'http://somewebsitethatdoesnotexist.com'
,
if
(
jQuery
.
ajax
({
url
:
'http://somewebsitethatdoesnotexist
-67864863574657654
.com'
,
success
:
function
(){
ok
(
false
,
"success"
);
},
error
:
function
(
xhr
,
_
,
e
){
ok
(
true
,
"file not found: "
+
xhr
.
status
+
" => "
+
e
);
},
complete
:
function
()
{
if
(
!
--
i
)
start
();
}
});
})
===
false
)
{
ok
(
true
,
"no transport"
);
if
(
!
--
i
)
start
();
}
jQuery
.
ajax
({
if
(
jQuery
.
ajax
({
url
:
'http://www.google.com'
,
success
:
function
(){
ok
(
false
,
"success"
);
},
error
:
function
(
xhr
,
_
,
e
){
ok
(
true
,
"access denied: "
+
xhr
.
status
+
" => "
+
e
);
},
complete
:
function
()
{
if
(
!
--
i
)
start
();
}
});
})
===
false
)
{
ok
(
true
,
"no transport"
);
if
(
!
--
i
)
start
();
}
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment