Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
JavaScript
  $.ajax({
 type: "POST",
 url: "CityNamesData.asmx/GetCities",
 contentType: "application/json; charset=utf-8",
 dataType: "json",
 success: function (data) {
 str = data.d;
}
});   
  var str1 = $.getJSON(jQuery.parseJSON(str));
                         return str1;




str contains

"[{"value":"1","text":"Amsterdam"},{"value":"2","text":"London"},{"value":"3","text":"Paris"},{"value":"4","text":"Washington"},{"value":"5","text":"Mexico City"},{"value":"6","text":"Buenos Aires"},{"value":"7","text":"Sydney"},{"value":"8","text":"Wellington"},{"value":"9","text":"Canberra"},{"value":"10","text":"Beijing"}]"

But str1 doesnt return above information

When I store same information in .json file then it is accessible with following code

return $.getJSON('assets/cities.json');

But when I am trying to retrieve same info from var str1 it gives following error


Uncaught TypeError: Cannot read property 'toString' of undefined bootstrap-tagsinput.js:226
Uncaught SyntaxError: Unexpected token u
Posted
Comments
Bernhard Hiller 22-Sep-14 8:16am    
"But str1 doesnt return above information" - what does it contain instead?
What about some kind of a list of key-value-pairs?
m-shraddha 23-Sep-14 10:21am    
str1 contains
"[{"value":"1","text":"Amsterdam"},{"value":"2","text":"London"},{"value":"3","text":"Paris"},{"value":"4","text":"Washington"},{"value":"5","text":"Mexico City"},{"value":"6","text":"Buenos Aires"},{"value":"7","text":"Sydney"},{"value":"8","text":"Wellington"},{"value":"9","text":"Canberra"},{"value":"10","text":"Beijing"}]"

But it doesnt return it

1 solution

Try this link
Click Here]
 
Share this answer
 
Comments
m-shraddha 22-Sep-14 4:03am    
Uncaught Syntax Error:Unexpected token u

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900