Dedent by using early returns.
This commit is contained in:
parent
b817a7e8b9
commit
68f52271f1
1 changed files with 18 additions and 14 deletions
|
@ -12,22 +12,26 @@ function _request(method, url, callback)
|
||||||
|
|
||||||
request.onreadystatechange = function()
|
request.onreadystatechange = function()
|
||||||
{
|
{
|
||||||
if (request.readyState == 4)
|
if (request.readyState != 4)
|
||||||
{
|
{
|
||||||
if (callback != null)
|
return;
|
||||||
{
|
|
||||||
if (request.status != 0)
|
|
||||||
{
|
|
||||||
response.completed = true;
|
|
||||||
response.data = JSON.parse(request.responseText);
|
|
||||||
}
|
|
||||||
response.meta = {
|
|
||||||
"request_url": url,
|
|
||||||
"status": request.status
|
|
||||||
}
|
|
||||||
callback(response);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (callback == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.status != 0)
|
||||||
|
{
|
||||||
|
response.completed = true;
|
||||||
|
response.data = JSON.parse(request.responseText);
|
||||||
|
}
|
||||||
|
response.meta = {
|
||||||
|
"request_url": url,
|
||||||
|
"status": request.status
|
||||||
|
}
|
||||||
|
callback(response);
|
||||||
};
|
};
|
||||||
var asynchronous = true;
|
var asynchronous = true;
|
||||||
request.open(method, url, asynchronous);
|
request.open(method, url, asynchronous);
|
||||||
|
|
Loading…
Reference in a new issue