Appending a List - No Styling - Can Anyone Help.

Appending a List - No Styling - Can Anyone Help.

Hi, I am trying to create my first Web App but have stumbled onto the following problem.   I want to append a list via an AJAX call but when I append the list no styling is applied to it.

  1.  <div id="resultLog"></div>
  2.         <ul data-role="listview" id="sample" data-inset="true" data-theme="a">
  3.               <li id="history"><a href="history.html">History</a></li>
  4.        </ul>
  5. </div>

And below is the AJAX call.

  1.     <script>
  2.         $(function() {
  3.  
  4.             $("#callAjax").click(function() {
  5.                 var theName = $.trim($("#theName").val());
  6.  
  7.                 if(theName.length > 0)
  8.                 {
  9.                     $.ajax({
  10.                       type: "POST",
  11.                       url: "http://localhost:8888/speedway_app/callajax.php",
  12.                       data: ({name: theName}),
  13.                       cache: false,
  14.                       dataType: "data",
  15.                       success: onSuccess
  16.                     });
  17.                 }
  18.             });
  19.  
  20.                 $("#resultLog").ajaxError(function(event, request, settings, exception) {
  21.                 $("#resultLog").html("Error Calling: " + settings.url + "<br />HTPP Code: " + request.status);
  22.             });
  23.  
  24.             function onSuccess(data)
  25.             {
  26. $("#resultLog").html("Result: " + data);
  27. $("#resultLog").append('<li id="james"><a href="asda.html?">Asda</a></li>');
  28.             }
  29.  
  30.         });
  31.     </script>

Many thanks in advance.
Paul.
    • Topic Participants

    • paul