【发布时间】:2014-06-18 00:17:04
【问题描述】:
我正在尝试使用直接链接从 box.com 获取 CSS 文件的内容并将其附加到 head 标签,但它不起作用。
$.ajax({
url: "https://app.box.com/shared/static/" + file_hash + ".css",
data: { client_id : '6guib1cgnk8uk2kdre45rjg7lt2xayegl94' },
type: "GET",
async: false,
crossDomain: true,
dataType: "text",
success: function (data) {
$("<style></style>").appendTo("head").html(data);
},
error: function (error) {
console.log(error);
}
}
);
有人解释如何使它工作吗?
它返回一个错误对象:
Object
abort: function ( statusText ) {
always: function () {
complete: function () {
done: function () {
error: function () {
fail: function () {
getAllResponseHeaders: function () {
getResponseHeader: function ( key ) {
overrideMimeType: function ( type ) {
pipe: function ( /* fnDone, fnFail, fnProgress */ ) {
progress: function () {
promise: function ( obj ) {
readyState: 0
responseText: undefined
setRequestHeader: function ( name, value ) {
state: function () {
status: 0
statusCode: function ( map ) {
statusText: "error"
success: function () {
then: function ( /* fnDone, fnFail, fnProgress */ )
【问题讨论】:
-
错误是什么?您在控制台或网络选项卡上看到了什么?是 JS 错误还是网络/请求错误?你能给出
file_hash的示例值吗? -
这里是 file_hash 的一个例子:app.box.com/shared/static/2mbz6a9olevi86oi43kk.css
-
网络标签中没有错误
-
我必须在家里检查一下,因为我无法访问我工作的
app.box.com。 -
您能否为此特定请求添加网络选项卡的图像?
标签: javascript ajax box-api