Javascript-форум (https://javascript.ru/forum/)
-   Библиотеки/Тулкиты/Фреймворки (https://javascript.ru/forum/library-toolkit-framework/)
-   -   Ка из JSON получить данные с js (https://javascript.ru/forum/library-toolkit-framework/64329-ka-iz-json-poluchit-dannye-s-js.html)

Arshak139 03.08.2016 13:57

Ка из JSON получить данные с js
 
Ка из данного JSON получить title как параметр с помощью js, спс за ответы
$(function() {
             //Activ'Map plugin init
             $('#activmap-wrapper').activmap({
                 places: [
                     {
                         title: 'Gorki Street Area',
                         address: '',
                         phone: '',
                         url:'https://visitgyumri.buildatourapp.com/gyumri-gorki-street/',
                         tags: ['gorki'],
                         lat: 40.787520,
                         lng: 43.858581,
                         img: 'stops/stop1/stop1railwaystation.jpg',
                         icon: 'images/1.png'
                     },
                     {
                         title: 'Central Sqaure Area',
                         address: '',
                         phone: '',
                         url:'https://visitgyumri.buildatourapp.com/gyumri-citysquare/',
                         tags: ['downtown'],
                         lat: 40.785227,
                         lng: 43.841713,
                         img: 'stops/stop2/stop2vardanantssquare.jpg',
                         icon: 'images/2.png'
                     },],});

ksa 04.08.2016 16:42

Цитата:

Сообщение от Arshak139
Ка из данного JSON

Это не JSON... :nono:
Это обычный объект.
Цитата:

Сообщение от Arshak139
получить title как параметр с помощью js

Как вариант...
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=windows-1251' />
<script src='http://code.jquery.com/jquery-latest.js'></script>
<!--
<script src="https://code.angularjs.org/1.3.9/angular.min.js"></script>
<script src="https://code.angularjs.org/1.3.9/angular-route.js"></script>
-->
<style type='text/css'>
</style>
<script type='text/javascript'>
$(function() {
	var o={
		places: [
			{
				title: 'Gorki Street Area',
				address: '',
				phone: '',
				url:'https://visitgyumri.buildatourapp.com/gyumri-gorki-street/',
				tags: ['gorki'],
				lat: 40.787520,
				lng: 43.858581,
				img: 'stops/stop1/stop1railwaystation.jpg',
				icon: 'images/1.png'
			},
			{
				title: 'Central Sqaure Area',
				address: '',
				phone: '',
				url:'https://visitgyumri.buildatourapp.com/gyumri-citysquare/',
				tags: ['downtown'],
				lat: 40.785227,
				lng: 43.841713,
				img: 'stops/stop2/stop2vardanantssquare.jpg',
				icon: 'images/2.png'
			}
		]
	};
	for (var i=0; i<o.places.length; i++) {
		alert(o.places[i].title);
	};
	// Activ'Map plugin init
	// $('#activmap-wrapper').activmap(o);
});
</script>
</head>
<body>
</body>
</html>


Часовой пояс GMT +3, время: 16:47.