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
7d58c0f9
Commit
7d58c0f9
authored
Nov 04, 2006
by
Klaus Hartl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed return type to undefined for certain functions, as discussed.
parent
7b780def
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
67 deletions
+67
-67
ajax.js
src/ajax/ajax.js
+67
-67
No files found.
src/ajax/ajax.js
View file @
7d58c0f9
...
@@ -69,12 +69,12 @@ jQuery.fn.extend({
...
@@ -69,12 +69,12 @@ jQuery.fn.extend({
load
:
function
(
url
,
params
,
callback
,
ifModified
)
{
load
:
function
(
url
,
params
,
callback
,
ifModified
)
{
if
(
url
.
constructor
==
Function
)
if
(
url
.
constructor
==
Function
)
return
this
.
bind
(
"load"
,
url
);
return
this
.
bind
(
"load"
,
url
);
callback
=
callback
||
function
(){};
callback
=
callback
||
function
(){};
// Default to a GET request
// Default to a GET request
var
type
=
"GET"
;
var
type
=
"GET"
;
// If the second parameter was provided
// If the second parameter was provided
if
(
params
)
{
if
(
params
)
{
// If it's a function
// If it's a function
...
@@ -82,16 +82,16 @@ jQuery.fn.extend({
...
@@ -82,16 +82,16 @@ jQuery.fn.extend({
// We assume that it's the callback
// We assume that it's the callback
callback
=
params
;
callback
=
params
;
params
=
null
;
params
=
null
;
// Otherwise, build a param string
// Otherwise, build a param string
}
else
{
}
else
{
params
=
jQuery
.
param
(
params
);
params
=
jQuery
.
param
(
params
);
type
=
"POST"
;
type
=
"POST"
;
}
}
}
}
var
self
=
this
;
var
self
=
this
;
// Request the remote document
// Request the remote document
jQuery
.
ajax
({
jQuery
.
ajax
({
url
:
url
,
url
:
url
,
...
@@ -115,7 +115,7 @@ jQuery.fn.extend({
...
@@ -115,7 +115,7 @@ jQuery.fn.extend({
/**
/**
* Serializes a set of input elements into a string of data.
* Serializes a set of input elements into a string of data.
* This will serialize all given elements. If you need
* This will serialize all given elements. If you need
* serialization similar to the form submit of a browser,
* serialization similar to the form submit of a browser,
* you should use the form plugin. This is also true for
* you should use the form plugin. This is also true for
* selects with multiple attribute set, only a single option
* selects with multiple attribute set, only a single option
...
@@ -138,7 +138,7 @@ jQuery.fn.extend({
...
@@ -138,7 +138,7 @@ jQuery.fn.extend({
serialize
:
function
()
{
serialize
:
function
()
{
return
jQuery
.
param
(
this
);
return
jQuery
.
param
(
this
);
},
},
evalScripts
:
function
()
{
evalScripts
:
function
()
{
return
this
.
find
(
'script'
).
each
(
function
(){
return
this
.
find
(
'script'
).
each
(
function
(){
if
(
this
.
src
)
if
(
this
.
src
)
...
@@ -148,7 +148,7 @@ jQuery.fn.extend({
...
@@ -148,7 +148,7 @@ jQuery.fn.extend({
eval
.
call
(
window
,
this
.
text
||
this
.
textContent
||
this
.
innerHTML
||
""
);
eval
.
call
(
window
,
this
.
text
||
this
.
textContent
||
this
.
innerHTML
||
""
);
}).
end
();
}).
end
();
}
}
});
});
// If IE is used, create a wrapper for the XMLHttpRequest object
// If IE is used, create a wrapper for the XMLHttpRequest object
...
@@ -175,7 +175,7 @@ if ( jQuery.browser.msie && typeof XMLHttpRequest == "undefined" )
...
@@ -175,7 +175,7 @@ if ( jQuery.browser.msie && typeof XMLHttpRequest == "undefined" )
* @param Function callback The function to execute.
* @param Function callback The function to execute.
* @cat AJAX
* @cat AJAX
*/
*/
/**
/**
* Attach a function to be executed whenever all AJAX requests have ended.
* Attach a function to be executed whenever all AJAX requests have ended.
*
*
...
@@ -189,7 +189,7 @@ if ( jQuery.browser.msie && typeof XMLHttpRequest == "undefined" )
...
@@ -189,7 +189,7 @@ if ( jQuery.browser.msie && typeof XMLHttpRequest == "undefined" )
* @param Function callback The function to execute.
* @param Function callback The function to execute.
* @cat AJAX
* @cat AJAX
*/
*/
/**
/**
* Attach a function to be executed whenever an AJAX request completes.
* Attach a function to be executed whenever an AJAX request completes.
*
*
...
@@ -203,7 +203,7 @@ if ( jQuery.browser.msie && typeof XMLHttpRequest == "undefined" )
...
@@ -203,7 +203,7 @@ if ( jQuery.browser.msie && typeof XMLHttpRequest == "undefined" )
* @param Function callback The function to execute.
* @param Function callback The function to execute.
* @cat AJAX
* @cat AJAX
*/
*/
/**
/**
* Attach a function to be executed whenever an AJAX request completes
* Attach a function to be executed whenever an AJAX request completes
* successfully.
* successfully.
...
@@ -218,7 +218,7 @@ if ( jQuery.browser.msie && typeof XMLHttpRequest == "undefined" )
...
@@ -218,7 +218,7 @@ if ( jQuery.browser.msie && typeof XMLHttpRequest == "undefined" )
* @param Function callback The function to execute.
* @param Function callback The function to execute.
* @cat AJAX
* @cat AJAX
*/
*/
/**
/**
* Attach a function to be executed whenever an AJAX request fails.
* Attach a function to be executed whenever an AJAX request fails.
*
*
...
@@ -232,7 +232,7 @@ if ( jQuery.browser.msie && typeof XMLHttpRequest == "undefined" )
...
@@ -232,7 +232,7 @@ if ( jQuery.browser.msie && typeof XMLHttpRequest == "undefined" )
* @param Function callback The function to execute.
* @param Function callback The function to execute.
* @cat AJAX
* @cat AJAX
*/
*/
/**
/**
* @test stop(); var counter = { complete: 0, success: 0, error: 0 };
* @test stop(); var counter = { complete: 0, success: 0, error: 0 };
* var success = function() { counter.success++ };
* var success = function() { counter.success++ };
...
@@ -253,7 +253,7 @@ if ( jQuery.browser.msie && typeof XMLHttpRequest == "undefined" )
...
@@ -253,7 +253,7 @@ if ( jQuery.browser.msie && typeof XMLHttpRequest == "undefined" )
* start();
* start();
* }});
* }});
* }});
* }});
* @test stop(); var counter = { complete: 0, success: 0, error: 0 };
* @test stop(); var counter = { complete: 0, success: 0, error: 0 };
* counter.error = 0; counter.success = 0; counter.complete = 0;
* counter.error = 0; counter.success = 0; counter.complete = 0;
* var success = function() { counter.success++ };
* var success = function() { counter.success++ };
...
@@ -272,15 +272,15 @@ if ( jQuery.browser.msie && typeof XMLHttpRequest == "undefined" )
...
@@ -272,15 +272,15 @@ if ( jQuery.browser.msie && typeof XMLHttpRequest == "undefined" )
* start();
* start();
* }});
* }});
* }});
* }});
*
*
* @name ajaxHandlersTesting
* @name ajaxHandlersTesting
* @private
* @private
*/
*/
new
function
(){
new
function
(){
var
e
=
"ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess"
.
split
(
","
);
var
e
=
"ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess"
.
split
(
","
);
for
(
var
i
=
0
;
i
<
e
.
length
;
i
++
)
new
function
(){
for
(
var
i
=
0
;
i
<
e
.
length
;
i
++
)
new
function
(){
var
o
=
e
[
i
];
var
o
=
e
[
i
];
jQuery
.
fn
[
o
]
=
function
(
f
){
jQuery
.
fn
[
o
]
=
function
(
f
){
...
@@ -320,9 +320,9 @@ jQuery.extend({
...
@@ -320,9 +320,9 @@ jQuery.extend({
* ok( content[1] == 'blublu', 'Check second tab');
* ok( content[1] == 'blublu', 'Check second tab');
* start();
* start();
* });
* });
*
*
* @name $.get
* @name $.get
* @type
jQuery
* @type
undefined
* @param String url The URL of the page to load.
* @param String url The URL of the page to load.
* @param Hash params A set of key/value pairs that will be sent to the server.
* @param Hash params A set of key/value pairs that will be sent to the server.
* @param Function callback A function to be executed whenever the data is loaded.
* @param Function callback A function to be executed whenever the data is loaded.
...
@@ -334,10 +334,10 @@ jQuery.extend({
...
@@ -334,10 +334,10 @@ jQuery.extend({
callback
=
data
;
callback
=
data
;
data
=
null
;
data
=
null
;
}
}
// append ? + data or & + data, in case there are already params
// append ? + data or & + data, in case there are already params
if
(
data
)
url
+=
((
url
.
indexOf
(
"?"
)
>
-
1
)
?
"&"
:
"?"
)
+
jQuery
.
param
(
data
);
if
(
data
)
url
+=
((
url
.
indexOf
(
"?"
)
>
-
1
)
?
"&"
:
"?"
)
+
jQuery
.
param
(
data
);
// Build and start the HTTP Request
// Build and start the HTTP Request
jQuery
.
ajax
({
jQuery
.
ajax
({
url
:
url
,
url
:
url
,
...
@@ -347,7 +347,7 @@ jQuery.extend({
...
@@ -347,7 +347,7 @@ jQuery.extend({
}
}
});
});
},
},
/**
/**
* Load a remote page using an HTTP GET request, only if it hasn't
* Load a remote page using an HTTP GET request, only if it hasn't
* been modified since it was last retrieved. All of the arguments to
* been modified since it was last retrieved. All of the arguments to
...
@@ -375,7 +375,7 @@ jQuery.extend({
...
@@ -375,7 +375,7 @@ jQuery.extend({
* });
* });
*
*
* @name $.getIfModified
* @name $.getIfModified
* @type
jQuery
* @type
undefined
* @param String url The URL of the page to load.
* @param String url The URL of the page to load.
* @param Hash params A set of key/value pairs that will be sent to the server.
* @param Hash params A set of key/value pairs that will be sent to the server.
* @param Function callback A function to be executed whenever the data is loaded.
* @param Function callback A function to be executed whenever the data is loaded.
...
@@ -406,7 +406,7 @@ jQuery.extend({
...
@@ -406,7 +406,7 @@ jQuery.extend({
* ok( true, "Check with single argument, can't verify" );
* ok( true, "Check with single argument, can't verify" );
*
*
* @name $.getScript
* @name $.getScript
* @type
jQuery
* @type
undefined
* @param String url The URL of the page to load.
* @param String url The URL of the page to load.
* @param Function callback A function to be executed whenever the data is loaded.
* @param Function callback A function to be executed whenever the data is loaded.
* @cat AJAX
* @cat AJAX
...
@@ -418,7 +418,7 @@ jQuery.extend({
...
@@ -418,7 +418,7 @@ jQuery.extend({
jQuery
.
get
(
url
,
null
,
null
,
"script"
);
jQuery
.
get
(
url
,
null
,
null
,
"script"
);
}
}
},
},
/**
/**
* Load a remote JSON object using an HTTP GET request.
* Load a remote JSON object using an HTTP GET request.
* All of the arguments to the method (except URL) are optional.
* All of the arguments to the method (except URL) are optional.
...
@@ -450,7 +450,7 @@ jQuery.extend({
...
@@ -450,7 +450,7 @@ jQuery.extend({
* });
* });
*
*
* @name $.getJSON
* @name $.getJSON
* @type
jQuery
* @type
undefined
* @param String url The URL of the page to load.
* @param String url The URL of the page to load.
* @param Hash params A set of key/value pairs that will be sent to the server.
* @param Hash params A set of key/value pairs that will be sent to the server.
* @param Function callback A function to be executed whenever the data is loaded.
* @param Function callback A function to be executed whenever the data is loaded.
...
@@ -463,7 +463,7 @@ jQuery.extend({
...
@@ -463,7 +463,7 @@ jQuery.extend({
jQuery
.
get
(
url
,
data
,
"json"
);
jQuery
.
get
(
url
,
data
,
"json"
);
}
}
},
},
/**
/**
* Load a remote page using an HTTP POST request. All of the arguments to
* Load a remote page using an HTTP POST request. All of the arguments to
* the method (except URL) are optional.
* the method (except URL) are optional.
...
@@ -493,7 +493,7 @@ jQuery.extend({
...
@@ -493,7 +493,7 @@ jQuery.extend({
* });
* });
*
*
* @name $.post
* @name $.post
* @type
jQuery
* @type
undefined
* @param String url The URL of the page to load.
* @param String url The URL of the page to load.
* @param Hash params A set of key/value pairs that will be sent to the server.
* @param Hash params A set of key/value pairs that will be sent to the server.
* @param Function callback A function to be executed whenever the data is loaded.
* @param Function callback A function to be executed whenever the data is loaded.
...
@@ -510,7 +510,7 @@ jQuery.extend({
...
@@ -510,7 +510,7 @@ jQuery.extend({
}
}
});
});
},
},
// timeout (ms)
// timeout (ms)
timeout
:
0
,
timeout
:
0
,
...
@@ -564,10 +564,10 @@ jQuery.extend({
...
@@ -564,10 +564,10 @@ jQuery.extend({
* });
* });
* // reset timeout
* // reset timeout
* $.ajaxTimeout(0);
* $.ajaxTimeout(0);
*
*
*
*
* @name $.ajaxTimeout
* @name $.ajaxTimeout
* @type
jQuery
* @type
undefined
* @param Number time How long before an AJAX request times out.
* @param Number time How long before an AJAX request times out.
* @cat AJAX
* @cat AJAX
*/
*/
...
@@ -577,7 +577,7 @@ jQuery.extend({
...
@@ -577,7 +577,7 @@ jQuery.extend({
// Last-Modified header cache for next request
// Last-Modified header cache for next request
lastModified
:
{},
lastModified
:
{},
/**
/**
* Load a remote page using an HTTP request. This function is the primary
* Load a remote page using an HTTP request. This function is the primary
* means of making AJAX requests using jQuery. $.ajax() takes one property,
* means of making AJAX requests using jQuery. $.ajax() takes one property,
...
@@ -588,7 +588,7 @@ jQuery.extend({
...
@@ -588,7 +588,7 @@ jQuery.extend({
* (String) type - The type of request to make (e.g. "POST" or "GET").
* (String) type - The type of request to make (e.g. "POST" or "GET").
*
*
* (String) url - The URL of the page to request.
* (String) url - The URL of the page to request.
*
*
* (String) data - A string of data to be sent to the server (POST only).
* (String) data - A string of data to be sent to the server (POST only).
*
*
* (String) dataType - The type of data that you're expecting back from
* (String) dataType - The type of data that you're expecting back from
...
@@ -684,13 +684,13 @@ jQuery.extend({
...
@@ -684,13 +684,13 @@ jQuery.extend({
* });
* });
*
*
* @name $.ajax
* @name $.ajax
* @type
jQuery
* @type
undefined
* @param Hash prop A set of properties to initialize the request with.
* @param Hash prop A set of properties to initialize the request with.
* @cat AJAX
* @cat AJAX
*/
*/
//ajax: function( type, url, data, ret, ifModified ) {
//ajax: function( type, url, data, ret, ifModified ) {
ajax
:
function
(
s
)
{
ajax
:
function
(
s
)
{
var
fvoid
=
function
()
{};
var
fvoid
=
function
()
{};
s
=
jQuery
.
extend
({
s
=
jQuery
.
extend
({
global
:
true
,
global
:
true
,
...
@@ -705,9 +705,9 @@ jQuery.extend({
...
@@ -705,9 +705,9 @@ jQuery.extend({
url
:
null
url
:
null
},
s
);
},
s
);
/*
/*
// If only a single argument was passed in,
// If only a single argument was passed in,
// assume that it is a object of key/value pairs
// assume that it is a object of key/value pairs
if ( !url ) {
if ( !url ) {
ret = type.complete;
ret = type.complete;
var success = type.success;
var success = type.success;
...
@@ -721,35 +721,35 @@ jQuery.extend({
...
@@ -721,35 +721,35 @@ jQuery.extend({
type = type.type;
type = type.type;
}
}
*/
*/
// Watch for a new set of requests
// Watch for a new set of requests
if
(
s
.
global
&&
!
jQuery
.
active
++
)
if
(
s
.
global
&&
!
jQuery
.
active
++
)
jQuery
.
event
.
trigger
(
"ajaxStart"
);
jQuery
.
event
.
trigger
(
"ajaxStart"
);
var
requestDone
=
false
;
var
requestDone
=
false
;
// Create the request object
// Create the request object
var
xml
=
new
XMLHttpRequest
();
var
xml
=
new
XMLHttpRequest
();
// Open the socket
// Open the socket
xml
.
open
(
s
.
type
,
s
.
url
,
true
);
xml
.
open
(
s
.
type
,
s
.
url
,
true
);
// Set the correct header, if data is being sent
// Set the correct header, if data is being sent
if
(
s
.
data
)
if
(
s
.
data
)
xml
.
setRequestHeader
(
"Content-Type"
,
"application/x-www-form-urlencoded"
);
xml
.
setRequestHeader
(
"Content-Type"
,
"application/x-www-form-urlencoded"
);
// Set the If-Modified-Since header, if ifModified mode.
// Set the If-Modified-Since header, if ifModified mode.
if
(
s
.
ifModified
)
if
(
s
.
ifModified
)
xml
.
setRequestHeader
(
"If-Modified-Since"
,
xml
.
setRequestHeader
(
"If-Modified-Since"
,
jQuery
.
lastModified
[
s
.
url
]
||
"Thu, 01 Jan 1970 00:00:00 GMT"
);
jQuery
.
lastModified
[
s
.
url
]
||
"Thu, 01 Jan 1970 00:00:00 GMT"
);
// Set header so the called script knows that it's an XMLHttpRequest
// Set header so the called script knows that it's an XMLHttpRequest
xml
.
setRequestHeader
(
"X-Requested-With"
,
"XMLHttpRequest"
);
xml
.
setRequestHeader
(
"X-Requested-With"
,
"XMLHttpRequest"
);
// Make sure the browser sends the right content length
// Make sure the browser sends the right content length
if
(
xml
.
overrideMimeType
)
if
(
xml
.
overrideMimeType
)
xml
.
setRequestHeader
(
"Connection"
,
"close"
);
xml
.
setRequestHeader
(
"Connection"
,
"close"
);
// Wait for a response to come back
// Wait for a response to come back
var
onreadystatechange
=
function
(
isTimeout
){
var
onreadystatechange
=
function
(
isTimeout
){
// The transfer is complete and the data is available, or the request timed out
// The transfer is complete and the data is available, or the request timed out
...
@@ -758,7 +758,7 @@ jQuery.extend({
...
@@ -758,7 +758,7 @@ jQuery.extend({
var
status
=
jQuery
.
httpSuccess
(
xml
)
&&
isTimeout
!=
"timeout"
?
var
status
=
jQuery
.
httpSuccess
(
xml
)
&&
isTimeout
!=
"timeout"
?
s
.
ifModified
&&
jQuery
.
httpNotModified
(
xml
,
s
.
url
)
?
"notmodified"
:
"success"
:
"error"
;
s
.
ifModified
&&
jQuery
.
httpNotModified
(
xml
,
s
.
url
)
?
"notmodified"
:
"success"
:
"error"
;
// Make sure that the request was successful or notmodified
// Make sure that the request was successful or notmodified
if
(
status
!=
"error"
)
{
if
(
status
!=
"error"
)
{
// Cache Last-Modified header, if ifModified mode.
// Cache Last-Modified header, if ifModified mode.
...
@@ -766,47 +766,47 @@ jQuery.extend({
...
@@ -766,47 +766,47 @@ jQuery.extend({
try
{
try
{
modRes
=
xml
.
getResponseHeader
(
"Last-Modified"
);
modRes
=
xml
.
getResponseHeader
(
"Last-Modified"
);
}
catch
(
e
)
{}
// swallow exception thrown by FF if header is not available
}
catch
(
e
)
{}
// swallow exception thrown by FF if header is not available
if
(
s
.
ifModified
&&
modRes
)
if
(
s
.
ifModified
&&
modRes
)
jQuery
.
lastModified
[
s
.
url
]
=
modRes
;
jQuery
.
lastModified
[
s
.
url
]
=
modRes
;
// If a local callback was specified, fire it
// If a local callback was specified, fire it
if
(
s
.
success
)
if
(
s
.
success
)
s
.
success
(
jQuery
.
httpData
(
xml
,
s
.
dataType
),
status
);
s
.
success
(
jQuery
.
httpData
(
xml
,
s
.
dataType
),
status
);
// Fire the global callback
// Fire the global callback
if
(
s
.
global
)
if
(
s
.
global
)
jQuery
.
event
.
trigger
(
"ajaxSuccess"
);
jQuery
.
event
.
trigger
(
"ajaxSuccess"
);
// Otherwise, the request was not successful
// Otherwise, the request was not successful
}
else
{
}
else
{
// If a local callback was specified, fire it
// If a local callback was specified, fire it
if
(
s
.
error
)
s
.
error
(
xml
,
status
);
if
(
s
.
error
)
s
.
error
(
xml
,
status
);
// Fire the global callback
// Fire the global callback
if
(
s
.
global
)
if
(
s
.
global
)
jQuery
.
event
.
trigger
(
"ajaxError"
);
jQuery
.
event
.
trigger
(
"ajaxError"
);
}
}
// The request was completed
// The request was completed
if
(
s
.
global
)
if
(
s
.
global
)
jQuery
.
event
.
trigger
(
"ajaxComplete"
);
jQuery
.
event
.
trigger
(
"ajaxComplete"
);
// Handle the global AJAX counter
// Handle the global AJAX counter
if
(
s
.
global
&&
!
--
jQuery
.
active
)
if
(
s
.
global
&&
!
--
jQuery
.
active
)
jQuery
.
event
.
trigger
(
"ajaxStop"
);
jQuery
.
event
.
trigger
(
"ajaxStop"
);
// Process result
// Process result
if
(
s
.
complete
)
s
.
complete
(
xml
,
status
);
if
(
s
.
complete
)
s
.
complete
(
xml
,
status
);
// Stop memory leaks
// Stop memory leaks
xml
.
onreadystatechange
=
function
(){};
xml
.
onreadystatechange
=
function
(){};
xml
=
null
;
xml
=
null
;
}
}
};
};
xml
.
onreadystatechange
=
onreadystatechange
;
xml
.
onreadystatechange
=
onreadystatechange
;
// Timeout checker
// Timeout checker
if
(
s
.
timeout
>
0
)
if
(
s
.
timeout
>
0
)
setTimeout
(
function
(){
setTimeout
(
function
(){
...
@@ -821,14 +821,14 @@ jQuery.extend({
...
@@ -821,14 +821,14 @@ jQuery.extend({
xml
=
null
;
xml
=
null
;
}
}
},
s
.
timeout
);
},
s
.
timeout
);
// Send the data
// Send the data
xml
.
send
(
s
.
data
);
xml
.
send
(
s
.
data
);
},
},
// Counter for holding the number of active queries
// Counter for holding the number of active queries
active
:
0
,
active
:
0
,
// Determines if an XMLHttpRequest was successful or not
// Determines if an XMLHttpRequest was successful or not
httpSuccess
:
function
(
r
)
{
httpSuccess
:
function
(
r
)
{
try
{
try
{
...
@@ -852,7 +852,7 @@ jQuery.extend({
...
@@ -852,7 +852,7 @@ jQuery.extend({
return
false
;
return
false
;
},
},
/* Get the data out of an XMLHttpRequest.
/* Get the data out of an XMLHttpRequest.
* Return parsed XML if content-type header is "xml" and type is "xml" or omitted,
* Return parsed XML if content-type header is "xml" and type is "xml" or omitted,
* otherwise return plain text.
* otherwise return plain text.
...
@@ -869,32 +869,32 @@ jQuery.extend({
...
@@ -869,32 +869,32 @@ jQuery.extend({
// Get the JavaScript object, if JSON is used.
// Get the JavaScript object, if JSON is used.
if
(
type
==
"json"
)
eval
(
"data = "
+
data
);
if
(
type
==
"json"
)
eval
(
"data = "
+
data
);
// evaluate scripts within html
// evaluate scripts within html
if
(
type
==
"html"
)
jQuery
(
"<div>"
).
html
(
data
).
evalScripts
();
if
(
type
==
"html"
)
jQuery
(
"<div>"
).
html
(
data
).
evalScripts
();
return
data
;
return
data
;
},
},
// Serialize an array of form elements or a set of
// Serialize an array of form elements or a set of
// key/values into a query string
// key/values into a query string
param
:
function
(
a
)
{
param
:
function
(
a
)
{
var
s
=
[];
var
s
=
[];
// If an array was passed in, assume that it is an array
// If an array was passed in, assume that it is an array
// of form elements
// of form elements
if
(
a
.
constructor
==
Array
||
a
.
jquery
)
{
if
(
a
.
constructor
==
Array
||
a
.
jquery
)
{
// Serialize the form elements
// Serialize the form elements
for
(
var
i
=
0
;
i
<
a
.
length
;
i
++
)
for
(
var
i
=
0
;
i
<
a
.
length
;
i
++
)
s
.
push
(
a
[
i
].
name
+
"="
+
encodeURIComponent
(
a
[
i
].
value
)
);
s
.
push
(
a
[
i
].
name
+
"="
+
encodeURIComponent
(
a
[
i
].
value
)
);
// Otherwise, assume that it's an object of key/value pairs
// Otherwise, assume that it's an object of key/value pairs
}
else
{
}
else
{
// Serialize the key/values
// Serialize the key/values
for
(
var
j
in
a
)
for
(
var
j
in
a
)
s
.
push
(
j
+
"="
+
encodeURIComponent
(
a
[
j
]
)
);
s
.
push
(
j
+
"="
+
encodeURIComponent
(
a
[
j
]
)
);
}
}
// Return the resulting serialization
// Return the resulting serialization
return
s
.
join
(
"&"
);
return
s
.
join
(
"&"
);
}
}
...
...
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