jQuery Ajax Request 200但状态错误

时间:2012-11-05 23:10:23

标签: javascript ajax jquery coffeescript

我正在测试一个Ajax表单,我得到了我没想到的行为。请求返回http 200 OK,但xhr状态为0,错误。我正在针对requestb.in进行测试。

这是我的功能(在coffeescript中):

$.ajax
  type: 'POST'
  url: 'http://requestb.in/1fcyas71'
  dataType: 'json'
  data: { foo: "bar" }
  error: (xhr, status, error) ->
    $('div#response').text(error).addClass('error')
    console.log status
    console.log xhr
  success: (data, status, xhr) ->
    $('div#response').text(data).removeClass('error')
    console.log status
    console.log xhr

我的理解是requestb.in接受任何请求,为什么这会返回错误?

1 个答案:

答案 0 :(得分:2)

您无法执行跨域请求。可能这是问题,因为你不认为你是http://requestb.in的雇员?

相关问题