Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to show some data from an API in a simple HTML div and it would be super helpful if anyone could help me with my code below. Here is the API: http://api.scb.se/OV0104/v1/doris/sv/ssd/START/JO/JO0601/SkordarL

Here is the JSON question that I want to send:
{
  "query": [
    {
      "code": "Region",
      "selection": {
        "filter": "vs:RegionRiket99",
        "values": []
      }
    },
    {
      "code": "Groda",
      "selection": {
        "filter": "item",
        "values": [
          "50"
        ]
      }
    },
    {
      "code": "ContentsCode",
      "selection": {
        "filter": "item",
        "values": [
          "JO0601L2"
        ]
      }
    },
    {
      "code": "Tid",
      "selection": {
        "filter": "item",
        "values": [
          "2000",
          "2001",
          "2002",
          "2003",
          "2004",
          "2005",
          "2006",
          "2007",
          "2008",
          "2009",
          "2010",
          "2011",
          "2012",
          "2013",
          "2014",
          "2015",
          "2016",
          "2017"
        ]
      }
    }
  ],
  "response": {
    "format": "px"
  }
}


What I have tried:

Here is my AJAX request so far:
$.ajax({
       url: "http://api.scb.se/OV0104/v1/doris/sv/ssd/START/JO/JO0601/SkordarL",
       type: "POST",
       dataType:'json',
       success: function () {
           console.log();
},
       error: function(error){
           console.log("Error!", error);
       }
   });


Thanks for any advice!

//Chris
Posted
Comments
Richard Deeming 17-May-18 9:57am    
If you want to send data to the server, then you need to include it in your AJAX request:
jQuery.ajax() | jQuery API Documentation[^]

You need to add the data parameter to your settings:
dataType:'json',
data: {
  "query": [
    ...
  ],
  "response": {
    "format": "px"
  }
},

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900