javascript - Ajax append to a variable with condition -


this code:

 $.ajax('http://mydb.php', {      datatype: "json",      jsonp: "jsoncallback",      method: 'get',      contenttype: 'application/json',      success: function (data, status) {          var _ul = $('<ul />').attr('data-role', 'listview');           $.each(data, function (i, item) {              $('<li />').append($('<a href="#p'+item.id+'" >'+item.nome+'</a>'))              .appendto(_ul);              var makepage = $('<div id="header">');              //append </div> makepage var              makepage.appendto($.mobile.pagecontainer);          });           $('#output').empty().append(_ul).enhancewithin();//.listview();      },      error: function (xhr, d, s) {          $('#output').empty().html(s);      }  }); 

i want append content var makepage. need this:

if ( item.something != " " )  

and append makepage following:

<div>something print since item.something not empty</div> 

and of course @ end have close "divs" opened @ begin of makepage variable.

how do it? have done same thing <ul> , <li> before, i'm not able same makepage var.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -