jquery mobile listview with php not showing corectly -


i populate listview mysql , php, when response text falls in html, shows plain text, not listview. html code:

<div data-role="page" id="myevents" data-theme="a"> <?php include("profileheader.php");?> <div data-role="main" class="ui-content" > <div data-role="collapsible" data-collapsed="false"><h2>my events</h2> <ul data-role="listview" id="myeventslist" data-inset="true"> </ul></div>     </div> 

this script in html file:

<script> $(document).on("pagecreate","#myevents",function(){ var xmlhttp = new xmlhttprequest();     xmlhttp.onreadystatechange = function() {         if (xmlhttp.readystate == 4 && xmlhttp.status == 200) {             document.getelementbyid("myeventslist").innerhtml = xmlhttp.responsetext;         }     }     xmlhttp.open("get", "myeventslist.php", true);     xmlhttp.send();  }); 

and php script (myeventslist.php file):

//before pdo statement     $myeventslist = '';     foreach($stmtmyeventslist->fetchall(pdo::fetch_assoc) $myeventsrow){         $myeventslist .= '<li>' . $myeventsrow['eventname'] . '</li>';          }   $db=null; // closing connection  } catch (pdoexception $e) { //echo $e->getmessage(); echo "error. try again in 15 minutes"; die(); }  echo $myeventslist; 

but results not expected :( : heh, have no reputation level 10 post picture

i found solution. in html script block must contain:

$("#myeventslist").append(xmlhttp.responsetext);             $("#myeventslist").listview('refresh'); 

instead of:

document.getelementbyid("myeventslist").innerhtml = xmlhttp.responsetext; 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -