2013-04-26 92 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