问题
Using d3.json to make a json request works while $.getJson and $.ajax fail. It is not a cross-domain problem as I am requesting a script on the same domain.
d3.json('api.php?q=/user/authUser?authemail=email%26authpassword=pass', function(d) {
console.log(d);
});
In console --> network, the d3 request correctly shows api.php as the path but with $.getJson or $.ajax I get the web service route (web.myapp.local) as the path.
Isn't d3.json just a wrapper for $.getJson. If so, why is the request path different for each.
回答1:
I figured out the problem, I was using mockjax, a javascript library to intercept ajax calls and it was causing the problems. Solved it by completely removing the library.
This might not be a problem with the latest releases - but it was at the time
来源:https://stackoverflow.com/questions/10622414/d3-json-works-but-getjson-fails