W
W
Waksim2017-09-11 02:05:38
JavaScript
Waksim, 2017-09-11 02:05:38

How to parse Json from another site using Jquery or JS?

It is necessary to process json located at the link testlodtask20172.azurewebsites.net/task/qyfgqiyhwfoq1
and json at this link testlodtask20172.azurewebsites.net/task in Jquery or Js.
The problem is that I don't know how to refer to the format and format code{"name":"Stan Smith","sex":"male","age":30}

[{"id":"qyfgqiyhwfoq1","name":"Stan Smith","sex":"male"},{"id":"qmvqqwrqsds2","name":"Jack Anderson","sex":"male"} ... ]


I load json like this: (but I would love to take a look at your connection methods)
$.ajax({
    url: 'http://testlodtask20172.azurewebsites.net/task/qyfgqiyhwfoq1',
    type: 'GET',
    dataType: 'jsonp',
    crossDomain: true,   
});

Please help, there is a lot of work, but everything got up because of this problem

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Evgeny Kalibrov, 2017-09-11
@Waksim

var response = // Ваш AJAX запрос
var jsonObj = JSON.parse(response);

// Печатаем в консоль id из вторых фигурных скобок
console.log(jsonObj[1].id);

I
iRedds, 2017-09-11
@iRedds

JSON - JavaScript Object Notation
This is a regular JS object represented as a string.
JSON.parse() to the rescue

A
alvvi, 2017-09-11
@alvvi

You can use the abbreviation

$.getJSON( "testlodtask20172.azurewebsites.net/task", function( data ) {
  // в data ваш объект
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question