2013-04-26 94 views
2

林制造ajax调用看起来像这样:GET Twitter的/用户/显示/返回错误:400错误:404(AJAX)

$.ajax({ 
    type:"GET", 
    dataType: "jsonp", 
    url:"https://api.twitter.com/1.1/users/show.json?user_id="+twitterId, 
    contentType:"application/json", 
    success:apiSuccessCallback, 
    error:apiFailCallback 
}); 

和IM包括jsonp作为一种解决方法跨域的问题。不过,我收到以下错误:

Failed to load resource: the server responded with a status of 404 (Not Found) 

Failed to load resource: the server responded with a status of 400 (Bad Request) 

如果你想知道我的success是一个简单的警告声明,我error是一样的。

任何人有任何建议吗?

+0

是你让从'https'请求域? – 2013-04-26 01:05:33

+0

我不是在https中,但我尝试了https,并且得到了相同的错误 – 2013-04-26 01:10:18

+0

是否调用了'apiFailCallback'? – 2013-04-26 01:16:40

回答

1

我会尝试包括suppress_response_codeshttps://dev.twitter.com/docs/error-codes-responses

$.ajax({ 
    type:"GET", 
    dataType: "jsonp", 
    data: { 
     suppress_response_codes: true 
    }, 
    url:"https://api.twitter.com/1.1/users/show.json?user_id="+twitterId, 
    contentType:"application/json", 
    success:apiSuccessCallback, 
    error:apiFailCallback 
}); 

从文档 -

If this parameter is present, all responses will be returned with a 200 OK status code - even errors. This parameter exists to accommodate Flash and JavaScript applications running in browsers that intercept all non-200 responses.

+0

我不认为它的问题与反应被压制...是否因为我需要验证此API调用? – 2013-04-26 01:38:36

+0

这可能是问题,对不起,我认为你已通过身份验证。 – 2013-04-26 01:59:11

+0

你是对的......我现在正在进行认证过程......无论如何 – 2013-04-26 03:04:43