Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

ajax send NOT WORKING

$
0
0

im trying to fetch data from database , but its not working and in the console im not getting any errorss... below is my code

<input type="text" id="t1" />

<br />
<input type="button" value="search" onclick="search1()" />

<br />

<p id="demo"></p>


</div>



</form>

<script type="text/javascript">


function search1()


{
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML = this.responseText;
}
};


xhttp.open("GET", "insert.aspx?opr=search&nm1="+document.getElementById('t1').value,true);
xhttp.send(null);

// document.getElementById("d1").innerHTML = xmlhttp.responseText;


}

</script>

and in my insert.aspx.cs code 

SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=xxxx;Integrated Security=True;Pooling=False");

string name;
string gender;
string opr;

if (opr == "search") {



name = Request.QueryString["nm1"].ToString();
conn.Open();
SqlCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT * FROM tbl_thesaurus where Word like (N'"+name.ToString()+"%')";
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);


foreach (DataRow dr in dt.Rows)
{



Response.Write(dr["Word"].ToString()); Response.Write("</br>");
Response.Write(dr["meaning"].ToString()); Response.Write("</br>");
Response.Write(dr["ressource"].ToString()); Response.Write("</br>");


}

conn.Close();

}


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>