Skip to content

Javascript access repsonse of API

I am somehow stuck. Probably this is an easy question, but I just can’t get it working.

I am trying to access a response from an API (mapquest), but I can not find a way to dig into the reponse to extract the relevant information. Here is my console-log and my code, I actually want to access the responseJSON and some stuff in there (results).

var convertAddress = function(){
    var PLZ = $("#PLZ").val();
    var Ort = $("#Ort").val();
    var Landkreis = $("#Landkreis").val();
    var Umkreis = $("#Umkreis").val();
    document.getElementById("lokalisierung").style.zIndex = "-1"; 
    var url = ',' + PLZ ;
    var D = $.ajax({
        type: "GET",
        url: url,
        dataType: "json"
//    console.log(PLZ);
//    console.log(Ort);
//    console.log(Landkreis);
//    console.log(Umkreis);


I found this stringify stuff on SO; but nothing worked as I expected, so probably there is a basic problem here.



You can access ur data with .done method. More information in official documentation jQuery Ajax

  .done(function(data) {
    // ur data
  .fail(function() {
    alert( "error" );
  .always(function() {
    alert( "complete" );

Done method is called when async call is done.

User contributions licensed under: CC BY-SA
7 People found this is helpful