Chinna Netha

Chinna Netha

  • NA
  • 282
  • 137k

jQuery AJAX call not working when URL Routing is used in web

Jul 22 2015 1:15 AM


Jquery ajax call not working when URL Routing is used in asp.net web forms
 
$("#fb_submit").bind("click", function () {
var fb_login_users = {};
fb_login_users.email = $("#fb_email").val();
fb_login_users.id = $("#fb_id").val();
$.ajax({
type: "POST",
url: '<%=Page.ResolveClientUrl("~/user.aspx/controlfb") %>',
data: '{email: "' + user.email + '" }',
data: '{id: "' + user.id + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
alert("User has been added successfully.");

}
});
return false;
});
 
[WebMethod]
[ScriptMethod]
public static void fb_user(users users)
{
string contr = ConfigurationManager.ConnectionStrings["con"].ConnectionString;
using (SqlConnection con = new SqlConnection(contr))
{
using (SqlCommand cmd = new SqlCommand("insert into fb_users values(@email,@id)"))
{
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@email", users.email);
cmd.Parameters.AddWithValue("@id", users.id);
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
 
 
 
 

Answers (7)