<thead>
<tr class="success">
<th>AccountName</th>
<th>AccountSite</th>
<th>ParentAccount</th>
<th>AccountNumber</th>
<th>AnnualRevenue</th>
<th>Employees</th>
<th>Rating</th>
<th>AccountType</th>
<th>Ownerships</th>
<th>Industry</th>
</tr>
</thead>
<tbody data-bind="foreach: allaccounts">
<tr class="active">
<td>
<label data-bind="html: AccountName"></label>
</td>
<td>
<label data-bind="html: AccountSite"></label>
</td>
<td>
<label data-bind="html: ParentAccount"></label>
</td>
<td>
<label data-bind="html: AccountNumber"></label>
</td>
<td>
<label data-bind="html:AnnualRevenue"></label>
</td>
<td>
<label data-bind="html: Employees"></label>
</td>
<td>
<label data-bind="html: Rating"></label>
</td>
<td>
<label data-bind="html: AccountType"></label>
</td>
<td>
<label data-bind="html: Ownerships"></label>
</td>
<td>
<label data-bind="html: Industry"></label>
</td>
<td><a data-bind="attr:{href:'/account/addedit/'+AccountId}" class="btn btn-primary btn-xs">Edit</a></td>
<td><a data-bind="attr:{href:'/account/SeeDetails/'+AccountId}" class="btn btn-primary btn-xs">Details</a></td>
<td><a data-bind="click: $root.delete" onclick=" Reloadpage()" class="btn btn-primary btn-xs">Delete</a></td>
</tr>
</tbody>
</table>
在这个页面我正在编写jquery添加脚本我已经调用了ajax 对于ajax我使用数据服务,datacontext和视图模型
getallaccountforgrid = function() {
$.ajax({
url: "/api/account/GetAllAccountForGrid",
type: 'GET',
dataType: 'json'
})
.done(function(data) {
if (data && data.IsSuccess) {
dataContext.allaccounts(data.Data);
}
})
.fail(function(error) {
console.log(error);
});
}
以上是数据服务代码
allaccounts = ko.observableArray([]),
return allaccounts :allaccounts
上面的代码是数据上下文代码 在此之后我使用视图模型进行连接 数据正确加载bt问题是jquery在ajax加载数据之前是否正在运行