javascript - NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load -
i trying simple request flipkart search api.
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();
after using asynchronous xmlhttprequest(),i following error:
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);
Comments
Post a Comment