title: Jquery ajax function to call code behind in vb file
body: <p>First of all, what i am trying to do is to populate a drop down box like this:</p>
  
  <pre><code>&lt;asp:DropDownList CssClass="ui dropdown" ID="drpGolfClub" runat="server"&gt;&lt;/asp:DropDownList&gt;
  </code></pre>
  
  <p>With some values giving me golf club id and names. The problem is that with jQuery i cant seem to run the code in the vb file behind. it all looks like this.
  In the aspx file: </p>
  
  <pre><code> function loadGolfClub()
          {
                  alert('inside method');
                  //debugger;
                  $.ajax({
                      type: "POST",
                      url: "Register.aspx/LoadGolfClub",
                      data: '{}',
                      contentType: "application/json; charset=utf-8",
                      dataType: "json",
                      async: false,
                      success: function (Result) {
  
                          debugger;
                          Result = Result.d;
                          $('#&lt;%=drpGolfClub.ClientID%&gt;').empty();
                          $('#&lt;%=drpGolfClub.ClientID%&gt;').prepend("&lt;option value='0'&gt;" +"Select" + "&lt;/option&gt;");
                          $.each(Result, function (key, value) {
                              $('#&lt;%=drpGolfClub.ClientID%&gt;').append($("&lt;option&gt;&lt;/option&gt;").val(value.GolfClubId).html(value.GolfClubName));
                              $('#&lt;%=drpGolfClub.ClientID%&gt;')[0].selectedIndex = 1;
                          });
                          alert("in sucess!");
                      },
  
                      failure: function () {
                          alert("Failed!");
                      }
                  });
              } 
  </code></pre>
  
  <p>The aspx file's vb behind is added like this:</p>
  
  <pre><code>Imports System
  Imports System.Linq
  Imports System.Web
  Imports System.Web.UI
  Imports Microsoft.AspNet.Identity
  Imports Microsoft.AspNet.Identity.EntityFramework
  Imports Microsoft.AspNet.Identity.Owin
  Imports Owin
  Imports System.Data
  Imports System.Web.Services
  Imports System.Reflection
  Imports Golfbook.CoreLibrary
  Imports Golfbook.CoreLibrary.Golfbook.Services
  
  
  Public Class Register
      Inherits System.Web.UI.Page
      Shared objGCBO As New GolfClubBO()
  
      Shared objGolfClubService As New Golfbook.CoreLibrary.Golfbook.Services.GolfClub.GolfClubDetails
  
      Shared details As New List(Of GolfClubBO)()
      Shared _loginName As String
      Shared loginName As String
  
      Private Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
  
      End Sub
  
      &lt;WebMethod()&gt;
          &lt;System.Web.Script.Services.ScriptMethod(ResponseFormat:=System.Web.Script.Services.ResponseFormat.Json)&gt;
          Public Shared Function LoadGolfClub() As GolfClubBO()
              Dim details As New List(Of GolfClubBO)()
              Try
                  details = objGolfClubService.LoadGolfClub()
              Catch ex As Exception
  
              End Try
              Return details.ToList.ToArray()
          End Function
  End Class
  </code></pre>
  
  <p>I know that page_load in vb is run, but it never goes to the function there. I have tried "everything" now, and have no idea what to do. the alert boxes added  in the function is trigging, so it do begin to run</p>
  
  <p>I know the JQuery is working cause i have added som values into a random textbox: $('#txtFirstName').val('Martin');</p>
  
  <p>Any tips on what can be the reason of this?</p>