Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Belgian Biodiversity Platform
yeti
Commits
8aedf0a5
Commit
8aedf0a5
authored
Mar 15, 2012
by
Julien Cigar
Browse files
Merge branch 'master' of
ssh://home.bebif.be/usr/local/repos/git/yeti
parents
86d6cbb4
f1c1e30e
Changes
1
Hide whitespace changes
Inline
Side-by-side
core.js
View file @
8aedf0a5
...
...
@@ -59,14 +59,21 @@
AjaxRequest
************************************************************************/
Yeti
.
AjaxRequest
=
function
(
target
,
opts
)
{
Yeti
.
AjaxRequest
=
function
(
url
,
opts
)
{
var
req
=
Yeti
.
XMLHttpRequest
(),
url
=
target
,
/* Request headers */
headers
=
{
'
X-Requested-With
'
:
'
XMLHttpRequest
'
,
'
Accept
'
:
'
text/javascript, text/html, application/xml, text/xml, */*
'
'
x-requested-with
'
:
'
XMLHttpRequest
'
},
/* Accept mapping */
accepts
=
{
json
:
'
application/json, text/json, text/javascript
'
,
html
:
'
text/html
'
,
xml
:
'
application/xml, text/xml
'
,
text
:
'
text/plain
'
}
/* Default options */
options
=
{
method
:
'
GET
'
,
...
...
@@ -75,10 +82,11 @@
charset
:
'
UTF-8
'
,
data
:
null
,
cache
:
true
,
accept
:
undefined
,
headers
:
{},
response_factory
:
Yeti
.
AjaxResponse
}
;
;
// var
/* Override default options */
for
(
var
i
in
opts
||
{})
{
...
...
@@ -95,7 +103,6 @@
/* Serialize parameters to a query string and append it to the URL if
* method is GET
*/
if
(
options
.
data
&&
typeof
(
options
.
data
)
!==
'
string
'
)
{
options
.
data
=
new
Yeti
.
Tools
.
Serializer
(
options
.
data
).
toString
();
if
(
options
.
method
===
'
GET
'
)
{
...
...
@@ -104,7 +111,6 @@
}
/* Append a timestamp to the url to avoid caching */
if
(
!
options
.
cache
)
{
var
__ts
=
'
__ts=
'
+
(
new
Date
()).
getTime
();
...
...
@@ -122,13 +128,17 @@
req
.
open
(
options
.
method
,
url
,
options
.
async
)
/* User-defined headers */
for
(
var
i
in
options
.
headers
)
{
headers
[
i
]
=
options
.
headers
[
i
];
headers
[
i
.
toLowerCase
()
]
=
options
.
headers
[
i
];
}
/* Set request headers */
/* Ensure that the "Accept" header is properly set */
if
(
!
headers
.
accept
)
{
headers
.
accept
=
accepts
[
options
.
accept
]
!==
undefined
?
accepts
[
options
.
accept
]
:
'
*/*
'
;
}
/* Set request headers */
for
(
var
i
in
headers
)
{
req
.
setRequestHeader
(
i
,
headers
[
i
]);
}
...
...
@@ -470,7 +480,9 @@
this
.
qs
=
[];
for
(
var
key
in
obj
)
{
this
.
_encodeValue
(
key
,
obj
[
key
]);
if
(
obj
.
hasOwnProperty
(
key
))
{
this
.
_encodeValue
(
key
,
obj
[
key
]);
}
}
}
...
...
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