Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery AJAX detect data change display in slideUp/Down motion
    text
    copied!<p>I want to build a commenting system for a news portal.</p> <p>I want jQuery AJAX to detect if anyone adds a comment data, it automatically updates the added comment in slideDown motion.</p> <p>How can I do that? Thanks.</p> <p>(Note: I'm using ASP.NET as server)</p> <p><img src="https://i.stack.imgur.com/RTebt.png" alt="enter image description here"></p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready(function () { $.ajax({ url: 'WebForm1.aspx', success: function (data) { $("#Urunler").html(data); } }); }); &lt;/script&gt; &lt;style&gt; li { width: 100px; height: 30px; background: yellow; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;ul id="Urunler" runat="server"&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Here is the code behind,</p> <pre><code>using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; namespace WebApplication2 { public partial class WebForm1 : System.Web.UI.Page { SqlConnection cnn = new SqlConnection("Initial Catalog=Northwind;Data Source=localhost;Integrated Security=SSPI;"); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { cnn.Open(); SqlCommand cmd = new SqlCommand("SELECT FirstName FROM Employees", cnn); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { Urunler.InnerHtml += "&lt;li&gt;" + dr.GetString(0) + "&lt;/li&gt;"; } } cnn.Close(); } } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload