0

Hi iam trying to store this JSON to my javascript array.Is there any way to that.am using following code and its not working at all.

my json JSON

 [{"id":"1","Intensity":"1","Location":"12.48,77.26"},{"id":"2","Intensity":"2","Location":"12.47,77.26"},{"id":"3","Intensity":"2","Location":"12.47,77.27"},{"id":"4","Intensity":"2","Location":"12.46,77.24"},{"id":"5","Intensity":"2","Location":"12.44,77.24"},{"id":"6","Intensity":"2","Location":"12.44,77.28"},{"id":"7","Intensity":"2","Location":"12.50,77.28"},{"id":"8","Intensity":"2","Location":"12.45,77.30"},{"id":"9","Intensity":"2","Location":"12.41,77.21"}]

my html code with JS for getting json data

<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script src="http://code.jquery.com/jquery-migrate-1.1.0.min.js"></script>
</head>
<body>
    <div id="response">werer</div>
    <script>
$.get('http://zonewebs.org/website/naveen/source/location.php', function(data) {
  $('#response').append(data);

});
</script>
</dody>
</html>

2 Answers 2

1

Use JSON.parse to convert valid json to javascript array

var dataArray = JSON.parse(data);
Sign up to request clarification or add additional context in comments.

5 Comments

u will get your json data into a javascript array using the above code.Then u can handle it as you like
As i see your json response there is no property in the json response. Instead of data.property use data
but its not working am getting blank page instead of jason data
You are using data.property. use data
$('#response').append(data );??
0

Your json is not valid.Try jsonlint. Remove this from the end :

{"var":"stuff"}

Then use :

JSON.parse(data);

1 Comment

how can i remove that part??

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.