I'm new to Jquery mobile. I'm trying to bind data to a listview. below is my code. when i run the page it's not showing the listview. please help.
My service Method
[WebMethod]
public static string[] GetNames() {
string[] names = {"chamara","janaka","asanka" };
return names;
}
My HTML code:
<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>
I have written things for you. Please find how each things are done.
Service
HTML
JavaScript
Final output
You can download the source here