title: jquery ajax loads page instead of asp.net web method
body: <p>I have a jQuery AJAX call that sends form object to the server.Actually i want to send the file object for this   iam using html input file and a input submit button.    </p>
  
  <pre><code>&lt;form id="form1" runat="server" method="post" enctype="multipart/form-data"&gt;
  &lt;input type="file" id="myFile" name="myFile" /&gt;
     &lt;input id="Button1" type="submit" value="Submit"  /&gt;
   &lt;form&gt;
  </code></pre>
  
  <p>Here is my submit click</p>
  
  <pre><code>  $('#Button1').click(function (event) {
     $.ajax({
                        type: "POST",
                        url: "Test.aspx/ag",
                        data: {},
                        processData: false,
                        contentType: false,                                
                        success: function (data) {
                            alert(data);
                        }
   });
  
   });
  </code></pre>
  
  <p>The code behind is following  </p>
  
  <pre><code> [System.Web.Services.WebMethod]  
      public static int ag()  
      {  
         HttpPostedFile file = HttpContext.Current.Request.Files["myFile"];  
      }  
  </code></pre>
  
  <p>The Webmethod is no longer being fired though, instead the Page_load of the page which the webmethod is on is  being fired. Why?  What can I do? In server side i want to get the file.I am using framework 4.0.</p>