NetworkError:无法执行'发送' on' XMLHttpRequest':无法加载

时间:2015-09-30 06:54:13

标签: javascript google-chrome-extension xmlhttprequest flipkart-api

我正在尝试对flipkart搜索API执行一个简单的GET请求。

  baseurl= 'https://affiliate-api.flipkart.net/affiliate/search/json?';
  params={
    query:name,
    resultCount:5
  };
  var xhr=new XMLHttpRequest();
  xhr.open('GET',baseurl+$.param(params),false);
  xhr.setRequestHeader("Fk-Affiliate-Id","myidhere");
  xhr.setRequestHeader("Fk-Affiliate-Token","mytokenhere");
  xhr.send();

enter image description here 使用异步XMLHttpRequest()后,我收到以下错误:

var xhr = new XMLHttpRequest();
  xhr.open("GET", baseurl+$.param(params), true);
  xhr.onload = function (e) {
    if (xhr.readyState === 4) {
      if (xhr.status === 200) {
        console.log("gowofee",xhr.responseText);
      } else {
        console.error("gowofee",xhr.statusText);
      }
    }
  };
  xhr.onerror = function (e) {
    console.error("gowofee",xhr.statusText);
  };
  xhr.setRequestHeader("Fk-Affiliate-Id","myid");
  xhr.setRequestHeader("Fk-Affiliate-Token","mytoken");
  xhr.send(null);

现在我收到此错误: enter image description here

0 个答案:

没有答案