首页 > AJAX的textStatus的值为error

AJAX的textStatus的值为error

$(document).ready(function() {
  var myDate = new Date();
  var myMonth = myDate.getMonth();
  var myDate = myDate.getDate();

  var myJSON = $.ajax({
    type: 'get',
    url: 'http://api.juheapi.com/japi/toh?key=80e392fb7e8d782cf46c7dc1eab9db91&v=1.0&month=11&day=1',
    data: {},
    success: function(msg) {
      alert(msg);
    },
    error: function(XMLHttpRequest, textStatus, errorThrown) {
      alert(XMLHttpRequest.status);
      alert(XMLHttpRequest.readyState);
      alert(textStatus);
    },

  })
})

上段代码执行结果XMLHttpRequest.status0XMLHttpRequest.readyState0textStatus的值为error,怎么破?

全部的代码在这里


你这个请求跨域了:

XMLHttpRequest cannot load http://api.juheapi.com/japi/toh?key=80e392fb7e8d782cf46c7dc1eab9db91&v=1.0&month=11&day=1. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://s.codepen.io' is therefore not allowed access.


你跨域了。请先解决跨域问题。可以考虑服务器做一次代理。

【热门文章】
【热门文章】