i want to retrive data from database every time 10 But When i Fire Ajax then Function Not Call . all Design Are Come In Response.
My Ajax Code In Default Page Where Add More Button .
$.ajax({
url: "scroll.aspx/GetDataFromServer",
data: "{}",
type: "POST",
success: function (data) {
alert(data);
console.log(data);
var data = $.trim(data);
if (data == "yes") {
alert("yes achived");
} else if (data == "no") {
alert("no nothing");
} else {
alert("Something should be wrong.");
}
}
});
somthing should be wrong aert comes.
my scroll page function ..
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();
// Set value of connection string here
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["coursesConnectionString"].ConnectionString);
con.Open();
// 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();
string divmaker = string.Empty; ;
for (int i = 1; i <= dcm.Tables[0].Rows.Count; i++)
{
string strComment = string.Empty;
divmaker += "<div class='col-md-4 col-sm-6 col-xs-12 every_course_box_layout' style='height:auto;'><div class='box02'><div style='width: 100%;float: left;'><a href='online_courses/course.aspx?course_id=" +dcm.Tables[0].Rows[0]["course_id"].ToString() + "'><img src=online_courses/" + dcm.Tables[0].Rows[0]["course_logo"].ToString()+ " height='150px' width='264px' alt=" + dcm.Tables[0].Rows[0]["course_name"].ToString() + "> </a></div>";
divmaker +="<h3><a class='course_name_heading' href='online_courses/course.aspx?course_id="+ dcm.Tables[0].Rows[0]["course_id"].ToString()+"'>"+ dcm.Tables[0].Rows[0]["course_name"].ToString() +"</a></h3>";
divmaker +="<div style='font-size:12px;'><table width='100%' border='0' cellspacing='0' cellpadding='0' class='tabl03'>";
divmaker +="<tbody><tr> <td align='center'><strong>Price:</strong> <span style='color:red;'>Free</span></td>";
divmaker +="<td align='center' style='width: 60%;'><strong>By:</strong> HawksCode Softwares Pvt. Ltd</td>";
divmaker +="</tr></tbody></table></div><div style='font-size:12px'>";
divmaker +="<table width='98%' border='0' cellspacing='3' cellpadding='0' style='margin:3px' align='center' class='selftbl'><tbody><tr>";
divmaker+="<td align='center'> <div align='right' class='viewicn'>(5k +) </div></td><td align='center'>";
////<i class="icon-signal" title="Lecture Rating"> </i><span id='votes_'>0.0</span>
divmaker+="<ul class='stars' id='item_' type='link' compact='' style='margin:0;background-position: 0px -87px!important;'>";
divmaker+="<li><a rel='star-1'> </a></li><li><a rel='star-2'> </a></li><li><a rel='star-3'> </a></li><li><a rel='star-4'> </a></li><li><a rel='star-5'> </a></li></ul></td>";
divmaker += "<td align='right' valign='middle'><a href='online_courses/course.aspx?course_id=" + dcm.Tables[0].Rows[0]["course_id"].ToString() + "' class='btn btn-success enroll-btn' style='float:right;' id='88'> Enroll </a></td></tr></tbody></table></div></div></div>";
}
return divmaker;
}
}
no output here please help me ..