I have json data in the format of the following:
{ "david" :12, "john": "21", "kevin": [{"address":"friendly"}]}}
this data is saved in my localhost web, in the URL : localhost8080/example/search?data=1
I want to use javascript/jQuery to save this data in a variable, and then parse the information i need later, I looked up for some ways to do this, I found the following:
$(document).ready(function () {
$.ajax({
type: 'GET',
url: 'localhost8080/example/search?data=1',
data: { get_param: 'value' },
success: function (data) {
var names = data
$('#a_div').html(data);
}
});
});
What is the line data: { get_param: 'value' }
doing? I dont want to get certain data, i want to save the entire json data and save it as a var like the following:
var example1 = { "david" :12, "john": "21", "kevin": [{"address":"friendly"}]}}
as my result. How should I do this?