title: can not get data form function using ajax jquery in asp.net c#
body: <p>i am trying use $.ajax() method in asp.net to fill a  html tag but i didn't get any data from on success parameter
  i am calling getData function from c# code and I tried to return a string but it doesn't work i also tried to user Response.write() but the same issue 
  when I  alert returned value it show me the aspx page code 
  as following image </p>
  
  <p><a href="https://i.stack.imgur.com/amX4r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/amX4r.png" alt="alert data image"></a></p>
  
  <p>here is my code 
  Default.apsx</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" 
   %&gt;
  
  &lt;!DOCTYPE html&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script&gt;
  
          $(document).ready(function () {
  
  
  
              $("#firstDrop").on("change", function () {
                  $.ajax({
                      url: "Default.aspx/getData",
                      type: "POST",
                      data: { id: $("#firstDrop").val() },
                      success: function (data) {
                          alert(data);
                          $("#secondDrop").html(data);
                      }
                  });
              });
  
          });
  
  
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
  
      &lt;select runat="server" id="firstDrop"&gt;
  
          &lt;option value="0"&gt;first select&lt;/option&gt;&lt;option value="1"&gt;second select&lt;/option&gt;&lt;option value="3"&gt;third select&lt;/option&gt;
  
      &lt;/select&gt;
          &lt;select id="secondDrop"&gt;&lt;/select&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Default.aspx.cs</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  
  public partial class _Default : System.Web.UI.Page
  {
      protected void Page_Load(object sender, EventArgs e)
      {
  
      }
  
  
      public  string getData()
      {
          return"&lt;option&gt;ABC&lt;/option&gt;&lt;option&gt;CDE&lt;/option&gt;";
      }
  }
  </code></pre>