Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
1a068884
...
1a0688849ed842c814aa55087f16030a59ddf7c4
authored
2012-11-10 17:27:09 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
simplified ClientUtils.sendAJAX()
1 parent
79aa3968
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
9 deletions
modules/clientutils.js
modules/clientutils.js
View file @
1a06888
...
...
@@ -569,24 +569,21 @@
* Performs an AJAX request.
*
* @param String url Url.
* @param String method HTTP method.
* @param String method HTTP method
(default: GET)
.
* @param Object data Request parameters.
* @param Boolean async Asynchroneous request? (default: false)
* @return String Response text.
*/
this
.
sendAJAX
=
function
sendAJAX
(
url
,
method
,
data
,
async
)
{
var
xhr
=
new
XMLHttpRequest
(),
dataString
=
""
;
if
(
typeof
method
!==
"string"
||
[
"GET"
,
"POST"
].
indexOf
(
method
.
toUpperCase
())
===
-
1
)
{
method
=
"GET"
;
}
else
{
method
=
method
.
toUpperCase
();
}
var
xhr
=
new
XMLHttpRequest
(),
dataString
=
""
,
dataList
=
[];
method
=
method
&&
method
.
toUpperCase
()
||
"GET"
;
xhr
.
open
(
method
,
url
,
!!
async
);
this
.
log
(
"
getBinary
(): Using HTTP method: '"
+
method
+
"'"
,
"debug"
);
this
.
log
(
"
sendAJAX
(): Using HTTP method: '"
+
method
+
"'"
,
"debug"
);
xhr
.
overrideMimeType
(
"text/plain; charset=x-user-defined"
);
if
(
method
===
"POST"
)
{
if
(
typeof
data
===
"object"
)
{
var
dataList
=
[];
for
(
var
k
in
data
)
{
dataList
.
push
(
encodeURIComponent
(
k
)
+
"="
+
encodeURIComponent
(
data
[
k
].
toString
()));
}
...
...
Please
register
or
sign in
to post a comment