weixin_33743248 2012-11-01 14:53 采纳率: 0%
浏览 56

JSON AJAX url想要更多

I am using D3 to create some county data with their choropleth example. I am using the d3.json option vs. the jquery .ajax. I have a URL that when I use it just does not load. After some research I found that the web service requires an additional parameter:

   {'county': {'year': 2002,'stat': 'crime'}} 

So the connection to this url keeps failing on me.

I tried to add the additional required parameters for the web service as follows:

d3.json("http://url/states", function (json) {
    data = "{'county': {'year': 2002,'stat': 'crime'}}"
    //basic d3 stuff from here below
    counties.selectAll("path")
        .attr("class", quantize);
    dataType = json,
        contentType = "application/json; charset=utf-8";
});

I just cannot connect without those params in the call and I am not sure how to incorporate them.

  • 写回答

2条回答 默认 最新

  • weixin_33704234 2012-11-01 14:57
    关注

    It might be that single quotes aren't being counted as valid syntax. You can validate your syntax at JSONLint.com

    Try double quotes instead

    data = '{"county": {"year": 2002, "stat": "crime"}}'
    
    评论

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制