d3.js - d3.request generates unauthorized error -
i using d3.request.js download data remote server requires http basic authentication. scripts are:
var query="<request-url>"; d3.request(query) .post() .user("login-id") .password("login-password") .get(function(error, data) { //scripts process result } )
<script src="https://d3js.org/d3-request.v1.min.js"></script> <script src="https://d3js.org/d3.v4.min.js"></script>
however upon executing above scripts, received 401 (unauthorized) error. have tested use $.ajax request method before switching d3.request. , working. hence should not cross domain issue remote server. result json object, tested using d3.json failed.
any suggestion problem?
thanks.
is cross-origin request? wag this problem. try this:
var query="<request-url>"; d3.request(query) .post() .user("login-id") .password("login-password") .on("beforesend", function(request) { request.withcredentials = true; }) .get(function(error, data) { //scripts process result } );
Comments
Post a Comment