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
44c240ff
...
44c240ff00252e436246984152db0647d7ac087e
authored
2011-10-23 08:16:12 +0200
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
better handling of ajax retrieval failures (more informative)
1 parent
913be452
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
casper.js
casper.js
View file @
44c240f
...
...
@@ -818,17 +818,26 @@
};
/**
* Retrieves string contents from a binary file behind an url.
* Retrieves string contents from a binary file behind an url. Silently
* fails but log errors.
*
* @param String url
* @return string
*/
this
.
getBinary
=
function
(
url
)
{
var
xhr
=
new
XMLHttpRequest
();
xhr
.
open
(
"GET"
,
url
,
false
);
xhr
.
overrideMimeType
(
"text/plain; charset=x-user-defined"
);
xhr
.
send
(
null
);
return
xhr
.
responseText
;
try
{
var
xhr
=
new
XMLHttpRequest
();
xhr
.
open
(
"GET"
,
url
,
false
);
xhr
.
overrideMimeType
(
"text/plain; charset=x-user-defined"
);
xhr
.
send
(
null
);
return
xhr
.
responseText
;
}
catch
(
e
)
{
if
(
e
.
name
===
"NETWORK_ERR"
&&
e
.
code
===
101
)
{
console
.
log
(
'unfortunately, casperjs cannot make cross domain ajax requests'
);
}
console
.
log
(
'error while fetching '
+
url
+
': '
+
e
);
return
""
;
}
};
/**
...
...
Please
register
or
sign in
to post a comment