-5

Пожалуйста, подскажите, как можно в .each(function(){}), динамически заполнить массив, чтобы привести его к такому виду:

var Coord = [[-123.77252789, 44.37857221], [-123.27252789, 44.17857221]];

Пробовал так, но результат отличается:

$.ajax({
            async: true,
            type: 'POST',
            url: '/Controller/Method',
            contentType: "application/json; charset=utf-8",                
            dataType: "json",
            success: function (data) {
                var Coord=[];
                $(data).each(function () {
                    Coord.push([this.x, this.y]);
                });
            }
        });
0

1 ответ 1

-3

Разобрался:

$.ajax({
            async: true,
            type: 'POST',
            url: '/Controller/Method',
            contentType: "application/json; charset=utf-8",                
            dataType: "json",
            success: function (data) {
                var Coord=[];
                $(data).each(function () {
                    Coord[index] = [this.x,this.y];
                });
            }
        });

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.