Dear sir,
my code is running correct and all information of table comes in alert giving the formate ..
but i want to retrive value in variable to append customized design result in ajax
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Text;
using System.IO;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Web.Script.Services;
public partial class LoadOnScroll_scroll : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static string GetDataFromServer()
{
DataSet dcm = new DataSet();
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["coursesConnectionString"].ConnectionString);
con.Open();
string res = "<p>No customer selected</p>";
// Write the select command value as first parameter
SqlCommand cm1 = new SqlCommand("Select * from courses where active='1' ",con);
SqlDataAdapter adp = new SqlDataAdapter(cm1);
int retVal = adp.Fill(dcm);
con.Close();
StringBuilder sb = new StringBuilder();
if (dcm.Tables[0].Rows.Count > 0)
{
foreach (DataRow Dr in dcm.Tables[0].Rows)
{
// sb.Append("<p>");
//sb.Append("<strong>" + Dr["course_id"].ToString() + "</strong><br />");
//sb.Append("<strong>" + Dr["course_name"].ToString() + "</strong><br />");
//sb.Append("<strong>" + Dr["course_logo"].ToString() + "</strong><br /></p>");
//res = sb.ToString();
return Dr;
}
}
}
}
its my page where function fire.
$(document).ready(function(){
alert('hi');
$.ajax({
url: "scroll.aspx/GetDataFromServer",
data: "{}",
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (data) {
alert(data.d);
var course = data.d;
$('#ctl00_ContentPlaceHolder1_result').append(data.d);
}
});
});
its my ajax function for retrive data from function ..
all works fine but my data comes in <p>.
i want to this data in div and table so how can retrive this data in ajax in a variable for customized design ...