I have the following code:
@{
ViewBag.Title = "Index";
}
<h2>
Index</h2>
<div data-role="page">
<div data-role="header">
...</div>
<div data-role="content">
<a id="btnShowCustomers" data-role="button" href="#secondDiv"></a>
</div>
<div data-role="footer">
...</div>
</div>
<div id="secondDiv" data-role="page">
<div id="list" data-role="content">
</div>
</div>
<div id="customerDetailsDiv" data-role="page">
<div data-role="content">
</div>
</div>
<script type="text/javascript">
$(document).ready(function (event) {
$('#btnShowCustomers').bind('vclick', function (event) {
GetCustomers();
});
});
function GetCustomers() {
var webMethod = "Home/GetCustomers";
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: webMethod,
data: "{}",
dataType: "json",
success: function (dataObj) {
$(dataObj).each(function () {
if ($(this).CanConsume) {
alert('can consume');
$('<a href="#" data-date="' + $(this).DateActivated + '" data-id="' + $(this).ID + '">' + $(this).Name + '</a>').appendTo('#list');
}
})
}
});
}
</script>
From the server-side I’m returning a list of Customer objects. Customer has the following properties;
- ID
- CanConsume (bool)
- Name
- DateActivated
I want to iterate through the returned set of results and build anchor elements and append them to a div named list. Do you have any idea why this is not working? I get no javascript errors.
jQuery kills errors… unfortunately.
If that does not work, please post some JSON.
damn to quick, again: