how to dynamically add collapsible set with json return data?
Hi,
I'm trying to add collapsible set with json return data, but for whatever reason the result is look like this.
Please give me some advise on how to fix it~~
Thanks
Kevin
Here is my code
- <div data-role="content" align="center">
- <label for="search-basic">Search Input:</label>
- <input type="search" name="search" placeholder="Book Title, Author, or ISBN#" id="searchkeyword" value="" />
- <input type="button" id="search" value="Search" />
- <div data-role="collapsible-set" id="result"></div>
- <div id=""><b>price may change...</b></div>
- </div>
- <script>
- $(document).ready(function(e)
- {
- $("#search").click(function(e)
- {
- if ($("#searchkeyword").val() != "")
- {
- $("#result").empty();
- $.getJSON("query.php?action=buyback&keyword=" +$("#searchkeyword").val(), function(data)
- {
- if (data.length > 0)
- {
- for (var x = 0; x < data.length; x++)
- {
- var content = '<div data-role="collapsible" data-collapsed="true" class="ui-collapsible-contain"><h3>' + data[x].TITLE + '</h3><p>Author: ' + data[x].AUTHOR + '<br>ISBN:' + data[x].ISBN + '<br>Price: $' + data[x].PRICE + '</p></div>';
- $("#result").append(content).trigger('create');
- }
- $("#searchkeyword").val("");
- }
- });
- }
- });
- });