我是 Jquery 移动版的新手。我正在尝试将数据绑定到列表视图。下面是我的代码。当我运行页面时,它没有显示列表视图。请帮忙。
我的服务方式
[WebMethod]
public static string[] GetNames() {
string[] names = {"chamara","janaka","asanka" };
return names;
}
我的 HTML 代码:
<form id="form1" runat="server">
<div data-role="page" id="index">
<div data-role="header">
<h1>
demo</h1>
</div>
<div data-role="content">
<ul data-role="listview" data-inset="true" id="cars-data">
</ul>
</div>
</div>
<div data-role="page" id="cars">
<div data-role="header">
<a data-role="button" data-transition="none" data-theme="a" href="#index">Back</a>
<h1>
</h1>
</div>
<div data-role="content">
<ul data-role="listview" data-inset="true" id="car-data">
</ul>
<img src="" width="100%" style="height: auto;" id="car-img">
</div>
</div>
<script type="text/javascript" charset="utf-8">
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "PINCWebService.asmx/GetNames",
endlessScroll: true,
dataType: "json",
success: function (data) {
$("#car-data").html(data);
},
failure: function (msg) {
alert(msg);
}
});
</script>
</form>