add app.request, extend demo
This commit is contained in:
parent
d57a14d048
commit
d9848bacf7
3 changed files with 86 additions and 55 deletions
|
|
@ -110,4 +110,4 @@ Scrollbars
|
|||
.OxThemeClassic ::-webkit-scrollbar:active,
|
||||
.OxThemeClassic ::-webkit-scrollbar-thumb:vertical:active {
|
||||
background: rgb(192, 192, 192);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,6 +105,21 @@ requires
|
|||
return Ox.getset(self.options, Array.slice.call(arguments), self.change, that);
|
||||
};
|
||||
|
||||
that.request = function(fn, data, callback) {
|
||||
if(Ox.isFunction(data)) {
|
||||
callback = data;
|
||||
data = {};
|
||||
}
|
||||
return Ox.Request.send({
|
||||
url: self.options.requestURL,
|
||||
data: {
|
||||
"function": fn,
|
||||
data: JSON.stringify(data)
|
||||
},
|
||||
callback: callback
|
||||
});
|
||||
};
|
||||
|
||||
return that;
|
||||
|
||||
};
|
||||
|
|
@ -442,50 +457,59 @@ requires
|
|||
}
|
||||
|
||||
function error(request, status, error) {
|
||||
var $dialog = new Ox.Dialog({
|
||||
title: "Error: Remote request failed.",
|
||||
buttons: [
|
||||
new Ox.Button({
|
||||
value: "Details",
|
||||
click: function() {
|
||||
var $iframe = $("<iframe>"),
|
||||
iframe = $iframe[0].contentWindow;
|
||||
iframe.document.open();
|
||||
iframe.document.write(xhr.responseText);
|
||||
iframe.document.close();
|
||||
$dialog.close();
|
||||
$dialog = new Ox.Dialog({
|
||||
title: "Error: Remote request failed.",
|
||||
buttons: [
|
||||
new Ox.Button({
|
||||
value: "Close",
|
||||
click: function() {
|
||||
$dialog.close();
|
||||
}
|
||||
})
|
||||
],
|
||||
width: 800,
|
||||
height: 400
|
||||
})
|
||||
.append($iframe)
|
||||
.open();
|
||||
}
|
||||
}),
|
||||
new Ox.Button({
|
||||
value: "Close",
|
||||
click: function() {
|
||||
$dialog.close();
|
||||
}
|
||||
})
|
||||
]
|
||||
})
|
||||
.append(request.status + " " + request.statusText)
|
||||
.open();
|
||||
Ox.print({
|
||||
request: request,
|
||||
status: status,
|
||||
error: error
|
||||
});
|
||||
try {
|
||||
var result = JSON.parse(request.responseText);
|
||||
} catch(e) {
|
||||
var result = {status: {code:request.status, text:request.statusText}};
|
||||
}
|
||||
options.callback(result);
|
||||
if(result.status.code >= 500) {
|
||||
var $dialog = new Ox.Dialog({
|
||||
title: "Error: Remote request failed.",
|
||||
buttons: [
|
||||
new Ox.Button({
|
||||
value: "Details",
|
||||
click: function() {
|
||||
var $iframe = $("<iframe>");
|
||||
var iframe = $iframe[0].contentWindow;
|
||||
iframe.document.open();
|
||||
iframe.document.write(request.responseText);
|
||||
iframe.document.close();
|
||||
$dialog.close();
|
||||
$dialog = new Ox.Dialog({
|
||||
title: "Error: Remote request failed.",
|
||||
buttons: [
|
||||
new Ox.Button({
|
||||
value: "Close",
|
||||
click: function() {
|
||||
$dialog.close();
|
||||
}
|
||||
})
|
||||
],
|
||||
width: 800,
|
||||
height: 400
|
||||
})
|
||||
.append($iframe)
|
||||
.open();
|
||||
}
|
||||
}),
|
||||
new Ox.Button({
|
||||
value: "Close",
|
||||
click: function() {
|
||||
$dialog.close();
|
||||
}
|
||||
})
|
||||
]
|
||||
})
|
||||
.append(request.status + " " + request.statusText)
|
||||
.open();
|
||||
Ox.print({
|
||||
request: request,
|
||||
status: status,
|
||||
error: error
|
||||
});
|
||||
}
|
||||
|
||||
pending[options.id] = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue