Jquery JSON response is undefined

This question already has an answer here:

  • Access / process (nested) objects, arrays or JSON 18 answers
  • Parse JSON in JavaScript? [duplicate] 16 answers

  • Since the response is an array. You can loop through all elements like so

    response.forEach(function(data){
        console.log(data.latitude);
    });
    

    it is array you have to loop like this:

    $.each(response,function(index,item){
    
        console.log(item);
    
    });
    

    or if it will always be single item then you can access first index like this:

    console.log(reponse[0].latitude);
    condole.log(reponse[0].longitude);
    

    WORKING FIDDLE

    链接地址: http://www.djcxy.com/p/8502.html

    上一篇: Python 3.x舍入行为

    下一篇: JQuery的JSON响应是未定义的