title: Jquery POST combination with classic asp
body: <p>I have tried many ways of executing this but its not happening .. here is the deal .. I have data displayed in table rows, every row has its id representing id of the person I wanna delete. I use jquery to collect this id from row where my button is located, here is the code how I do that, its working I'm just writing so you can get an insight of what I'm trying to accomplish :</p>
  
  <pre><code>var customer_id = $(this).parents("tr").attr('id');
  </code></pre>
  
  <p>When I test it using alert it works, here is the difficult part I'm simply stuck I have file called Delete.aspx here is its content</p>
  
  <pre><code>&lt;%
  </code></pre>
  
  <p>string p = Request["value"];
      int pInt = Int32.Parse(p);</p>
  
  <pre><code>var dataContext = new CustomersDataContext();
  var customer = from m in dataContext.Customers
                 where m.id == pInt
                 select m;
  dataContext.Customers.DeleteAllOnSubmit(customer);
  dataContext.SubmitChanges();
  %&gt;
  </code></pre>
  
  <p>Now I'm trying to send the to the Delete.aspx values to delete person with particular id, and it works by typing Delete.aspx?value=7 in the browser, it deletes person with id 7. Now here is where I'm really really stuck. From Default.aspx i'm trying to reach Delete.aspx and pass the person id using jquery like this :</p>
  
  <pre><code>$(".btn-delete").click(function() {
                   var answer = confirm("If you press OK, this customer will be deleted?")
                   var customer_id = $(this).parents("tr").attr('id');
                   if (answer) {
  
  
                        $.ajax({
                       type: "POST",
                       url: "Delete.aspx",
                       data: "{value: '" + customer_id + "'}",
                       contentType: "application/json; charset=utf-8",
                       dataType: "json",
                       success: function(msg) {
                       AjaxSucceeded(msg);
                       },
                       error: AjaxFailed
  
                       });
  
                       $(this).parents("tr").animate({ backgroundColor: "#fbc7c7" }, "fast")
                  .animate({ opacity: "hide" }, "slow")
                       return false;
                   }
                   else {
                       alert("Customer has not been deleted!")
                   }
  
  
               });
  
               function AjaxSucceeded(result) {
                   alert(result.d);
               }
               function AjaxFailed(result) {
                   alert(result.status + ' ' + result.statusText);
               }
  
           });   
  </code></pre>
  
  <p>So now the result, When I click the button and confirm deletion I get "500 Internal server error", is this fixable or is there anymore other simple way of doing the same thing ?</p>
  
  <p>Thank you</p>
  
  <hr>
  
  <p>I've modified code .. but still I need some help .. I feel I'm so close so at least point me to right direction ..</p>
  
  <p>here is my Delete.aspx.cs</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  
  namespace Second_Question
  {
      public partial class Delete : System.Web.UI.Page
      {
          protected void Page_Load(object sender, EventArgs e)
          {
  
              string p = Request["value"];
              int pInt = Int32.Parse(p);
  
              var dataContext = new CustomersDataContext();
              var customer = from m in dataContext.Customers
                             where m.id == pInt
                             select m;
              dataContext.Customers.DeleteAllOnSubmit(customer);
              dataContext.SubmitChanges();
  
  
          }
      }
  }
  </code></pre>
  
  <p>here is my Delete.aspx </p>
  
  <p>
  </p>
  
  
  
  <p>
  </p>
  
  <p>any ideas ? thank you</p>