title: call ajax function in javascript
body: <p>I want to call Ajax in javascript but it gives CallPageMethod undefined error. How to define it? and I'm newbie in Ajax. Can you help me?</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;    
      function ValidateDelete() {
          var result = CallPageMethod("IsLangExists", success, fail);
  
          if (result == true) { 
              return confirm('Do you want to continue ?')
          }
          else alert('You can not delete this record');
      }
  
      function success(response) {
          //alert(response.d);
      }
  
      function fail(response) {
          //alert("An error occurred.");
      }
  &lt;/script&gt;
  &lt;asp:GridView ID="grdList" OnRowCommand="grdList_RowCommand"&gt;
      &lt;Columns&gt;
          &lt;asp:BoundField DataField="LangId" HeaderText="LangId" Visible="false" /&gt;            
          &lt;asp:TemplateField HeaderText="Delete"&gt;
                 &lt;ItemTemplate&gt;
                      &lt;asp:ImageButton ID="imgBtnDelete" runat="server" CommandName="_Delete" CommandArgument='&lt;%#Eval("LangId")%&gt;' ImageUrl="~/Image/delete_icon.gif" OnClientClick="return ValidateDelete();"
                              ToolTip="Delete" /&gt;
                &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
      &lt;/Columns&gt;           
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>code behind</p>
  
  <pre><code>[WebMethod]
  public static bool IsLangExists()
  {
      return true;
  }
  </code></pre>