这是我尝试通过跨域 ajax 请求访问的 JSON 的一部分:
{
"request": "Stream/GetDigest",
"response": {
"success": true,
"content": {
"0": {
"artifact_id": "36",
"timestamp": "2013-08-20 11:59:00",
"modified": "2013-08-20 11:59:00",
"text": "Why did the last one duplicate? I don't think I clicked it twice...",
"author_desc": "",
"object_type": "artifact",
"comments": []
},
等等....
这是我的ajax函数:
loadDigest: function() {
$.ajax({
crossDomain: true,
type: "GET",
dataType: "jsonp",
crossDomain: true,
async: true,
cache: false,
url: 'http://DOMAIN_NAME/Stream/GetDigest?digest_hash=43c4901481f7f1acd825537aa91a7dd36561d30e',
success: function(data) {
var source = $('#artifact_list').html(),
template = Handlebars.compile(source),
html = template(data.response);
$content_area.html(html);
},
error: function(error) {
$content_area.html('<strong>There was an error: ' + error + '</strong>');
},
timeout: default_timeout,
beforeSend: object_spinner, // calling variable for default loading graphic
complete: function() {
$content_area.removeClass('is_getting');
},
jsonp: 'jsonp-callback'
})
我得到了 200 OK 状态码,但是在控制台中,除了“GetDigest:1”上的“Uncaught SyntaxError: Unexpected token :”之外,我似乎什么也得不到。
我尝试了一些在 StackOverflow 和其他地方找到的不同方法,但似乎无法运行。任何帮助,将不胜感激。
谢谢!