Catch json parse errors, setting json_ok = false.
This commit is contained in:
parent
fbb373c37e
commit
1af8342202
1 changed files with 13 additions and 5 deletions
|
@ -18,15 +18,23 @@ function _request(method, url, callback)
|
||||||
if (callback == null)
|
if (callback == null)
|
||||||
{return;}
|
{return;}
|
||||||
|
|
||||||
if (request.status != 0)
|
|
||||||
{
|
|
||||||
response.completed = true;
|
|
||||||
response.data = JSON.parse(request.responseText);
|
|
||||||
}
|
|
||||||
response.meta = {
|
response.meta = {
|
||||||
"request_url": url,
|
"request_url": url,
|
||||||
"status": request.status
|
"status": request.status
|
||||||
}
|
}
|
||||||
|
if (request.status != 0)
|
||||||
|
{
|
||||||
|
response.completed = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
response.data = JSON.parse(request.responseText);
|
||||||
|
response.meta.json_ok = true;
|
||||||
|
}
|
||||||
|
catch (exc)
|
||||||
|
{
|
||||||
|
response.meta.json_ok = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
callback(response);
|
callback(response);
|
||||||
};
|
};
|
||||||
const asynchronous = true;
|
const asynchronous = true;
|
||||||
|
|
Loading…
Reference in a new issue