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
c639405c
Commit
c639405c
authored
Jan 25, 2010
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't set the context in .load() as it stops the global ajax events from firing. Fixes #5922.
parent
6a3d0996
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
3 deletions
+28
-3
ajax.js
src/ajax.js
+4
-3
ajax.js
test/unit/ajax.js
+24
-0
No files found.
src/ajax.js
View file @
c639405c
...
@@ -45,18 +45,19 @@ jQuery.fn.extend({
...
@@ -45,18 +45,19 @@ jQuery.fn.extend({
}
}
}
}
var
self
=
this
;
// Request the remote document
// Request the remote document
jQuery
.
ajax
({
jQuery
.
ajax
({
url
:
url
,
url
:
url
,
type
:
type
,
type
:
type
,
dataType
:
"html"
,
dataType
:
"html"
,
data
:
params
,
data
:
params
,
context
:
this
,
complete
:
function
(
res
,
status
)
{
complete
:
function
(
res
,
status
)
{
// If successful, inject the HTML into all the matched elements
// If successful, inject the HTML into all the matched elements
if
(
status
===
"success"
||
status
===
"notmodified"
)
{
if
(
status
===
"success"
||
status
===
"notmodified"
)
{
// See if a selector was specified
// See if a selector was specified
this
.
html
(
selector
?
self
.
html
(
selector
?
// Create a dummy div to hold the results
// Create a dummy div to hold the results
jQuery
(
"<div />"
)
jQuery
(
"<div />"
)
// inject the contents of the document in, removing the scripts
// inject the contents of the document in, removing the scripts
...
@@ -71,7 +72,7 @@ jQuery.fn.extend({
...
@@ -71,7 +72,7 @@ jQuery.fn.extend({
}
}
if
(
callback
)
{
if
(
callback
)
{
this
.
each
(
callback
,
[
res
.
responseText
,
status
,
res
]
);
self
.
each
(
callback
,
[
res
.
responseText
,
status
,
res
]
);
}
}
}
}
});
});
...
...
test/unit/ajax.js
View file @
c639405c
...
@@ -70,6 +70,30 @@ test("jQuery.ajax() - error callbacks", function() {
...
@@ -70,6 +70,30 @@ test("jQuery.ajax() - error callbacks", function() {
});
});
});
});
test
(
".load()) - 404 error callbacks"
,
function
()
{
expect
(
6
);
stop
();
jQuery
(
'#foo'
).
ajaxStart
(
function
(){
ok
(
true
,
"ajaxStart"
);
}).
ajaxStop
(
function
(){
ok
(
true
,
"ajaxStop"
);
start
();
}).
ajaxSend
(
function
(){
ok
(
true
,
"ajaxSend"
);
}).
ajaxComplete
(
function
(){
ok
(
true
,
"ajaxComplete"
);
}).
ajaxError
(
function
(){
ok
(
true
,
"ajaxError"
);
}).
ajaxSuccess
(
function
(){
ok
(
false
,
"ajaxSuccess"
);
});
jQuery
(
"<div/>"
).
load
(
"data/404.html"
,
function
(){
ok
(
true
,
"complete"
);
});
});
test
(
"jQuery.ajax() - abort"
,
function
()
{
test
(
"jQuery.ajax() - abort"
,
function
()
{
expect
(
6
);
expect
(
6
);
stop
();
stop
();
...
...
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