dear sir i Have An array value and send to an page for inserting on perticuler person ...
$(document).ready(function(){
var a=[];
var arr="";
$(".get_id").click(function(){
if($("#ctl00_ContentPlaceHolder1_add_hidden").val()!=null && $("#ctl00_ContentPlaceHolder1_add_hidden").val()!="")
{
alert("hello");
var clg_id=$(this).siblings(".clg_id").val();
var a_index=a.indexOf($(this).siblings(".clg_id").val());
alert(a_index);
if(a_index<0)
{
a.push(clg_id);
alert(a);
$('#Login_Register_btn1').click(function(){
$.ajax({
var dd=a;
type: "POST",
url: "update_add_college.aspx/UpdateCustomer",
data: "{'clgid': '" + dd + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
alert("User has been added successfully.");
window.location.reload();
}
});
return false;
});
}
else
{
}
working alert(a) values are 15,25,30,35 of clgid
update page codding
public class User
{
public string wid { get; set; }
public string usid { get; set; }
}
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static void UpdateCustomer(string clgid,string usid)
{
usid = HttpContext.Current.Response.Cookies["user_login"].Value;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["easyshikshaConnectionString"].ConnectionString);
con.Open();
SqlCommand cmd1 = new SqlCommand("Update user_Information set wishtlist_clg=@wid where user_id=@usid");
cmd1.Parameters.AddWithValue("@wid", clgid);
cmd1.Parameters.AddWithValue("@usid", usid);
cmd1.CommandType = CommandType.Text;
int count = cmd1.ExecuteNonQuery();
con.Close();
}
user id get from cookies ... if user login here..
but when we click on button then any response and not alert come from there ..
i want to insert this array value in database where user id is current cookies on page ....
please resolve this
i tried
http://www.aspsnippets.com/Articles/Insert-Update-Data-to-Database-with-jQuery-AJAX-and-WebMethod-in-ASPNet.aspx
http://www.aspsnippets.com/Articles/Save-Form-Data-to-Database-with-jQuery-AJAX-in-ASPNet.aspx