title: Calling a server side function written in webparts using ajax call in javascript
body: <p>I am using the below javascript function to call a function placed in a webpart file in my solution using ajax.
  Mainly, I am using webparts for my UI and controls are defined in the htm files and the webpart files load this htm files.</p>
  
  <p>The below java script function is written in Pdf.htm file. and my AddRecord function is written in a PdfPart.cs, But its throwin the error. How do I check whats going wrong, the error is wat i have mentioned in the javascript function, alert("Record saved successfully in database");</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $("#OpenPdf").click(
      function () {
          //write a record in the table.
          $.ajax({
            type: 'POST',
            contentType: "application/json; charset=utf-8",
            url: 'PdfPart.cs/AddRecord',
            //data: {'name': $('#txtname').val()},
            data: {'PdfId': PdfFullpaperlessModule},
            async: false,
            success: function (response) {
            alert("Record saved successfully in database");
            },
            error: function () {
            alert("some problem in saving data");
            }
    });    
  
                  });
  </code></pre>
  
  <p></p>
  
  <p>I Also have .aspx pages from which i direct it to the webparts.</p>