Error in splitting data from Ajax JSON format
Error in splitting data from Ajax JSON format
shanmugham
Posts: 1Questions: 0Answers: 0
I'm a mobile application developer , we need an Technical Help in JSON (JavaScript Object Notation) , Here we need to get data from server in JSON format . we can able to view the response from server using Firebug ..
But we find the Error (Undefined ) while splitting the JSON format array to individual String .but we can able to split from local workspace .we worked varied method to solve it. we need a guidance to that method .
For Example :
sample Json Format from http://qa-find.uglii.com/Home/GetCountries/9a3d0a019-e523-487f-8250-fd98c31b6a84.json
[{"i":"W07O5auPxEuqPchXazzI_g","n":"Afghanistan"},{"i":"IjdD3Z-fO0uACOVRhyUBmw","n":"Aland Islands"},..... etc ]
Response in JSON format as Above , we need to split into individual String such as
var country1 = Afghanistan ;
var country2 = Aland Islands;
my code is
----------------------------------------------------------------------------------
var url = "js/test.json";
//var url = "http://qa-find.uglii.com/Home/GetCountries/9a3d0a019-e523-487f-8250-fd98c31b6a84.json";
//Actual Json Url link is url = "http://qa-find.uglii.com/Home/GetCountries/9a3d0a019-e523-487f-8250-fd98c31b6a84.json"
// sample Json Url Link is url = "js/test.json"
$.ajax({
url: url,
contentType: "application/json; charset=utf-8",
dataType: "script",
type: "GET",
cache: false,
processData: false,
error: function (xhtr, response, e) {},
success: function (jsonData, status) {
var jo = eval(jsonData);
// error at jo.length as undefined
for (var i = 0; i < jo.length; i++) {
$("#addoptions").append(''+jo[i].n+'');
}
}
});
-----------------------------------------------------------------------------------
please help us to solve..
But we find the Error (Undefined ) while splitting the JSON format array to individual String .but we can able to split from local workspace .we worked varied method to solve it. we need a guidance to that method .
For Example :
sample Json Format from http://qa-find.uglii.com/Home/GetCountries/9a3d0a019-e523-487f-8250-fd98c31b6a84.json
[{"i":"W07O5auPxEuqPchXazzI_g","n":"Afghanistan"},{"i":"IjdD3Z-fO0uACOVRhyUBmw","n":"Aland Islands"},..... etc ]
Response in JSON format as Above , we need to split into individual String such as
var country1 = Afghanistan ;
var country2 = Aland Islands;
my code is
----------------------------------------------------------------------------------
var url = "js/test.json";
//var url = "http://qa-find.uglii.com/Home/GetCountries/9a3d0a019-e523-487f-8250-fd98c31b6a84.json";
//Actual Json Url link is url = "http://qa-find.uglii.com/Home/GetCountries/9a3d0a019-e523-487f-8250-fd98c31b6a84.json"
// sample Json Url Link is url = "js/test.json"
$.ajax({
url: url,
contentType: "application/json; charset=utf-8",
dataType: "script",
type: "GET",
cache: false,
processData: false,
error: function (xhtr, response, e) {},
success: function (jsonData, status) {
var jo = eval(jsonData);
// error at jo.length as undefined
for (var i = 0; i < jo.length; i++) {
$("#addoptions").append(''+jo[i].n+'');
}
}
});
-----------------------------------------------------------------------------------
please help us to solve..
This discussion has been closed.