将数据绑定到jtemplate时出现问题 [英] Problem while binding data to jtemplate
本文介绍了将数据绑定到jtemplate时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将数据绑定到jtemplete,但即使没有收到任何错误也失败了,
请帮帮我们..
这里我的Aspx代码
< script src = ../ js / jtemplates.js > < / script >
< script 类型 = text / javascript >
$(document).ready(function(){
$ .ajax({
类型:POST,
url:frmUser.aspx / GetUserList,
data:{},
contentType:application / json; charset = utf-8,
dataType:json,
success:function(data){
$('#userContainer')。setTemplateURL('../ JTemplate / User。 htm');
$('#userContainer')。processTemplate(data.d);
},
错误:function(){
alert(错误);
}
});
});
< / script >
< div id = userContainer >
< / div >
这里我的Cs页面代码
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Web;
使用System.Web.UI;
使用System.Web.UI.WebControls;使用System.Web.Services
;使用Bl
;
命名空间HotelManagementSystem.Masters
{
public partial class frmUser:System.Web.UI.Page
{
protected void Page_Load(object sender,EventArgs e)
{
// GetUserList();
}
[WebMethod]
公共静态列表< UserDetails > GetUserList()
{
return Bl.Users.GetUserList();
}
}
}
这里我的jtemplate
< div >
< ; h3 > 用户列表< / h3 >
{#foreach $ T as user}
< div > { $ T.user.FirstName} < / div > ;
{#/ for}
< / div >
解决方案
(document).ready(function(){
.ajax({
type:POST,
url:frmUser.aspx / GetUserList,
data:{},
contentType:application / json; charset = utf-8,
dataType:json,
success:function(data){
('#userContainer')。setTemplateURL('。 ./JTemplate/User.htm');
I am trying bind data to jtemplete, but failed even not getting any error ,
please help me guys..
Here My Aspx code
<script src="../js/jtemplates.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$.ajax({
type: "POST",
url: "frmUser.aspx/GetUserList",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
$('#userContainer').setTemplateURL('../JTemplate/User.htm');
$('#userContainer').processTemplate(data.d);
},
error: function () {
alert("Error");
}
});
});
</script>
<div id="userContainer">
</div>
Here My Cs Page Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using Bl;
namespace HotelManagementSystem.Masters
{
public partial class frmUser : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// GetUserList();
}
[WebMethod]
public static List <UserDetails> GetUserList()
{
return Bl.Users.GetUserList();
}
}
}
here my jtemplate
<div>
<h3>User List</h3>
{#foreach $T as user}
<div>{$T.user.FirstName}</div>
{#/for}
</div>
解决方案
(document).ready(function () {
.ajax({ type: "POST", url: "frmUser.aspx/GetUserList", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) {
('#userContainer').setTemplateURL('../JTemplate/User.htm');
这篇关于将数据绑定到jtemplate时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文