我从数据库要去负载鸣叫加载数据,但它不能正常工作,请检查在那里我做错误无法从数据库使用jQuery的ajax Asp.net web表单
这是div在哪里要加载的鸣叫
<div id="load_tweets">
</div>
这是准备函数内部的setInterval方法
setInterval(function() {
$('#load_tweets').load("CS.aspx/fetch").fadeIn("slow");
},1000);
,这是取[WEBMETHOD]
[System.Web.Services.WebMethod]
public static DataTable fetch()
{
SqlConnection con = new SqlConnection("data source=dbcomments;initial catalog=CommentSystemUsingAjax;integrated security=true");
SqlDataAdapter da = new SqlDataAdapter("select * from tbl_tweet order by tweet_id desc", con);
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
,我也尝试过这种方式
[System.Web.Services.WebMethod]
public static string fetch(string tweet)
{
SqlConnection con = new SqlConnection("data source=dbcomments;initial catalog=CommentSystemUsingAjax;integrated security=true");
SqlDataAdapter da = new SqlDataAdapter("select * from tbl_tweet order by tweet_id desc", con);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
tweet = dt.Rows[0]["tweet"].ToString();
}
return tweet;
}
请帮我
thnx但在fetchData()函数控制不进入$ .ajax({...我调试它直接从$控制跳过的脚本。ajax({到catch关闭花括号.....现在我该怎么办? – Heartlion
和我应该在哪里定义FetchData函数在document.ready函数内部还是外部document.ready函数? – Heartlion
保留FetchData函数如果条件 –