请有人帮助清除此错误
我想在不刷新页面的情况下每次单击动态框时显示一个模态弹出窗口(包含来自数据库的内部详细信息)。我使用了 jquery ajax,但我无法从数据库中获取值。它在弹出的字段中显示未定义的错误。请看代码。
<script type="text/javascript">
$.fx.speeds._default = 1000;
$(document).ready(function () {
$("div[id*='window']").live('click', function (e) {
$.ajax({
url: 'Default2.aspx/get_details',
type: 'Get',
// dataType: 'json',
data: { id: $(this).attr('id').replace(/window/g, '') },
success: function (data) {
alert(data);
$('<div></div>').appendTo('body').html('<div>' + data.comp_name + '</div><div>' + data.comp_status + '</div>').dialog({
modal: true, title: 'owner details', zIndex: 10000, autoOpen: true,
width: 400, height: 200, modal: false, resizable: false, closeOnEscape: false,
show: "slide", hide: "explode",
close: function (event, ui) {
$(this).remove();
}
});
}
});
});
});
</script>
c#代码:
public class Company
{
public int Id { get; set; }
public string Name { get; set; }
public string Status { get; set; }
}
public Company get_details(int id)
{
DataSet dset = new DataSet();
SqlConnection cn = new SqlConnection(@"Data Source=KUR;Initial Catalog=Drea;User ID=sa;Password=Sage");
string qry = "Select comp_companyId,comp_name,comp_status from Company where comp_companyId=" +id+" ";
SqlDataAdapter sda = new SqlDataAdapter(qry, cn);
sda.Fill(dset);
Company entity = new Company();
SqlCommand cmd = new SqlCommand(qry, cn);
SqlDataReader reader = cmd.ExecuteReader();
if (reader.Read())
{
entity.Id = int.Parse(reader["comp_companyId"].ToString());
entity.Name = reader["comp_name"].ToString();
entity.Status = reader["comp_status"].ToString();
}
return entity;
}