i am trying to use jquery ajax to pass data to server from client side.it should be super easy and it is.i added a static method in home.aspx and posted the data in there using ajax.but i have no idea why its always saying not found error.please any one can help me on that? here is my ajax code.

<script type="text/javascript">
   $(document).ready(function () {
       $('#form1home a').click(function () {
           var position = $(this).parent().attr("id");
           $.ajax({
               type: 'POST',
               url: 'home.aspx/clickaction',
               contentType: 'application/json',
               dataType: 'json',
               data:  JSON.stringify({ "position":position }),
               success: function () {
               },
               error: function (request, status, error) {
                   alert(request+" "+error);
               }
           });

       });

   });

i am also giving the static method thati used in c#.

[WebMethod]
public static void clickaction(string position)
{
    DataBaseClass db = new DataBaseClass();
    string qry = "select * from cms_tbl where position='" + position + "' and shopid='" + HttpContext.Current.Session["shopid"].ToString() + "'";
    DataTable dt = db.ConnectDataBaseReturnDT(qry);

    if (dt.Rows[0]["type"].ToString() == "product")
    {
        string path = "product.aspx?id=" + dt.Rows[0]["items"].ToString() + "&shop=" + HttpContext.Current.Session["shopid"].ToString();
        HttpContext.Current.Response.Redirect(path);
    }
    else if (dt.Rows[0]["type"].ToString() == "subcat")
    {
        string path = "productdisplay.aspx?id=" + dt.Rows[0]["items"].ToString() + "&sid=" + HttpContext.Current.Session["shopid"].ToString();
        HttpContext.Current.Response.Redirect(path);
    }
    else if (dt.Rows[0]["type"].ToString() == "brand")
    {
        string path = "productdisplay.aspx?bid=" + dt.Rows[0]["items"].ToString() + "&sid=" + HttpContext.Current.Session["shopid"].ToString();
        HttpContext.Current.Response.Redirect(path);
    }
}

Related posts

Recent Viewed