【发布时间】:2012-09-18 05:16:04
【问题描述】:
我希望在 RESTful 服务的身份验证成功后收到来自服务器的 JSON 响应。
我正在使用下面的代码:
jQuery.ajax({
type: "GET",
url: "http://dev.ragld.com/hostinfo/",
contentType: "json",
beforeSend: function(jqXHR){
jqXHR.setRequestHeader("Authorization", "Basic cmsdfsdfG~~~~~Q6cmFnbGQ=");
//some characters have been changed for security reasons.
},
accept: "application/json",
async:false,
success: function(response){
console.log('success called..');
},
error: function(errorObj){
console.log(errorObj);
}
});
由于某些原因,它没有选择GET 的方法,当我在FF 中检查firebug 的NET 选项卡时,它显示方法为OPTIONS 而不是GET。
同样,它不会返回我期望的 JSON 数据。
谁能帮忙?
编辑 来自chrome的错误,但它并没有说太多:
【问题讨论】:
标签: jquery json restful-authentication