How to retrieve JSON data from a Remote server?
How to retrieve JSON data from a Remote server?
srikanthreddy
Posts: 7Questions: 0Answers: 0
Hi Everyone,
I'm trying to display Json data on my JQuery datatable. The json data is on remote server, if the json data is on my server then i'm able to fetch and display the data on my datatable but i can't able to fetch the json data from a remote server . How can i get the json data from a remote server? . Following is my sample code.
This is the URL('http://xxx.xxx.xxx:8088/test/validGetMyApplications.json'; , on a remote server ) is having my JSON object, i'm trying to hit this URL and trying to pull the json data from this URL to display this data in Jquery Datatable.
but, when i'm trying with this following code it is not hitting the URL.
Any suggestions please. Thanks.
$(document).ready(function() {
$('#myapplicationstable').dataTable();
$.ajax({
url: 'http://xxx.xxx.xxx:8088/test/validGetMyApplications.json',
async: false,
dataType: 'json',
success: function (data) {
$.each(data.applicationMainList, function(key, item) {
$('#myapplicationstable').dataTable().fnAddData( [
item.Id,
item.appLink.linkName,
item.applicationIdName.applicationName,
item.appAcronym,
item.applicationOwner.name
]
);
});
}
});
} );
I'm trying to display Json data on my JQuery datatable. The json data is on remote server, if the json data is on my server then i'm able to fetch and display the data on my datatable but i can't able to fetch the json data from a remote server . How can i get the json data from a remote server? . Following is my sample code.
This is the URL('http://xxx.xxx.xxx:8088/test/validGetMyApplications.json'; , on a remote server ) is having my JSON object, i'm trying to hit this URL and trying to pull the json data from this URL to display this data in Jquery Datatable.
but, when i'm trying with this following code it is not hitting the URL.
Any suggestions please. Thanks.
$(document).ready(function() {
$('#myapplicationstable').dataTable();
$.ajax({
url: 'http://xxx.xxx.xxx:8088/test/validGetMyApplications.json',
async: false,
dataType: 'json',
success: function (data) {
$.each(data.applicationMainList, function(key, item) {
$('#myapplicationstable').dataTable().fnAddData( [
item.Id,
item.appLink.linkName,
item.applicationIdName.applicationName,
item.appAcronym,
item.applicationOwner.name
]
);
});
}
});
} );
This discussion has been closed.
Replies
Allan
Thanks a lot for your response.
But, my remote server gives me just json object(objectData), in the format is something like this :
{
"objectData":
{
"abc": "123",
"def": "456",
"ghi": {
"454": "abcdef",
"Id": "12324"
}
}
}
it is not having any callback to it. So, is that possible to get a json object without using jsonp(because i dont have a callback from remote server). Any Suggestion please.
Thanks,
Allan