JQuery Mobile Parse JSON for ListView -


this question has been asked lots , have spent last 3 days going through number of different 'solutions', none of can work.

i have huge json file, 150k entries, want view listview in jquery mobile. (i using filter use data)

the best have come this

<!doctype html> <html> <head> <title>test</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="css/jqm-docs.css" /> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" /> <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script> <script type="text/javascript" src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>     </head>  <body>     <div data-role="page">     <div data-role="content">         <div id="output">             <ul data-role="listview" data-inset="true" data-filter="true">              </ul>         </div>     </div> </div>   <script type="text/javascript">         //simulating json coming server var json = '["city1","city2","city3"]'; //jquery getjson step var data = $.parsejson(json);  //and code $.each(data, function (index, value) {         $('#output').children('ul').append('<p>'+value+'</p>').listview('refresh'); });  </script>   </body> </html> 

if remove .listview('refresh') 3 json entries listed in same listview field. want them seperated.

can advise on how this?

with thanks

tim

in order use $.parsejson first need have proper json string format

so guess variable

var json = '["city1","city2","city3"]'; 

should more like:

var json = '{"city":"city1"},{"city":"city2"},{"city":"city2"}'; 

then before convert json, rather want split first

var jsonsplit = json.split(','); 

and convert json every separated part within array

var data = new array(), i; for(i in jsonsplit){  if(jsonsplit[i].length){ //remove last empty element after .split()   data[i] = $.parsejson(jsonsplit[i]);  } } 

then can manipulate data javascript object


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -