forked from 0x2620/oxjs
requests, errors, dialogs
This commit is contained in:
parent
c9f854061c
commit
1bc0ffdfbd
5 changed files with 24 additions and 34 deletions
|
|
@ -477,16 +477,19 @@ requires
|
|||
|
||||
function error(request, status, error) {
|
||||
var data;
|
||||
Ox.print("error", request, status, error);
|
||||
try {
|
||||
data = JSON.parse(request.responseText);
|
||||
} catch (error) {
|
||||
data = {
|
||||
status: {
|
||||
code: request.status,
|
||||
text: request.statusText
|
||||
}
|
||||
};
|
||||
if (arguments.length == 1) {
|
||||
data = arguments[0]
|
||||
} else {
|
||||
try {
|
||||
data = JSON.parse(request.responseText);
|
||||
} catch (err) {
|
||||
data = {
|
||||
status: {
|
||||
code: request.status,
|
||||
text: request.statusText
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
if (data.status.code < 500) {
|
||||
callback(data);
|
||||
|
|
@ -516,13 +519,13 @@ requires
|
|||
})
|
||||
.append("Sorry, we have encountered an application error while handling your request. To help us find out what went wrong, you may want to report this error to an administrator. Otherwise, please try again later.")
|
||||
.open();
|
||||
// fixme: change this to Send / Don't Send
|
||||
Ox.print({
|
||||
request: request,
|
||||
status: status,
|
||||
error: error
|
||||
});
|
||||
}
|
||||
|
||||
pending[options.id] = false;
|
||||
}
|
||||
|
||||
|
|
@ -530,14 +533,15 @@ requires
|
|||
pending[options.id] = false;
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
} catch(error) {
|
||||
data = {
|
||||
} catch (err) {
|
||||
error({
|
||||
status: {
|
||||
code: 500,
|
||||
text: "Internal Server Error"
|
||||
},
|
||||
data: {}
|
||||
};
|
||||
});
|
||||
return;
|
||||
}
|
||||
cache[req] = {
|
||||
data: data,
|
||||
|
|
@ -1082,7 +1086,6 @@ requires
|
|||
.appendTo(that);
|
||||
that.$buttons = [];
|
||||
$.each(options.buttons, function(i, button) {
|
||||
console.log(button)
|
||||
that.$buttons[i] = new Ox.Button({
|
||||
size: "medium",
|
||||
value: button.value
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue