d3.json工作,但$ .getJson失败 [英] d3.json works but $.getJson fails

查看:407
本文介绍了d3.json工作,但$ .getJson失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 d3.json 发出json请求,而$ .getJson和$ .ajax失败。这不是一个跨域问题,因为我在同一个域上请求一个脚本。

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);

});

在控制台 - >网络中,d3请求正确地显示api.php作为路径,但$ .getJson或$ .ajax我获得web服务路由(web.myapp.local)作为路径。

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.

不是d3.json只是$的包装器。 getJson。如果是这样,为什么每个请求路径不同。

Isn't d3.json just a wrapper for $.getJson. If so, why is the request path different for each.

推荐答案

我想出了问题,我使用mockjax,库拦截ajax调用,这是导致的问题。

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

这篇关于d3.json工作,但$ .getJson失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆