Add attribute "completed" to response object.
This commit is contained in:
parent
b81aad78dd
commit
6cfa83e2d8
1 changed files with 13 additions and 6 deletions
|
@ -6,18 +6,25 @@ common._request =
|
||||||
function _request(method, url, callback)
|
function _request(method, url, callback)
|
||||||
{
|
{
|
||||||
var request = new XMLHttpRequest();
|
var request = new XMLHttpRequest();
|
||||||
|
var response = {
|
||||||
|
"completed": false,
|
||||||
|
};
|
||||||
|
|
||||||
request.onreadystatechange = function()
|
request.onreadystatechange = function()
|
||||||
{
|
{
|
||||||
if (request.readyState == 4)
|
if (request.readyState == 4)
|
||||||
{
|
{
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
{
|
{
|
||||||
var response = {
|
if (request.status != 0)
|
||||||
"meta": {},
|
{
|
||||||
"data": JSON.parse(request.responseText)
|
response["completed"] = true;
|
||||||
};
|
response["data"] = JSON.parse(request.responseText);
|
||||||
response["meta"]["request_url"] = url;
|
}
|
||||||
response["meta"]["status"] = request.status;
|
response["meta"] = {
|
||||||
|
"request_url": url,
|
||||||
|
"status": request.status
|
||||||
|
}
|
||||||
callback(response);
|
callback(response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue