1

I have a page called AddNews.aspx and in codebehind a web method called AddNews(Parameters)..

AddNews.aspx page is inherited from a master page.. So i used contentplaceholder.

I have a button..It's id is btnSave.

Here is jquery code:

$(function() {
 $("[id$='_btnSave']").click(function() {
  $.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    data: $.toJSON(veriler),
    url: "AddNews.aspx/AddNews",
    dataType: "json",
    success: function(result) {
      $("#result").html('News added');
    },
    error: function() {
      alert('Problem');
    }
  });
 });
});
</script>

Button click trigger now.. But it doesnt call Web Page Method.. What's the problem?

M4N
  • 94,805
  • 45
  • 217
  • 260
Grant83
  • 11
  • 1
  • 4

1 Answers1

1

Does your page method look similar to this: (c# assumed here) IF you have parameters (you say so) the names need to match exactly the ajax part.

[WebMethod]
        public static string GetServerTimeString()
        {
            return "Current Server Time: " + DateTime.Now.ToString();
        }

EDIT: you can reference my answer to this question for a page method with parameters: Jquery .ajax async postback on C# UserControl

Community
  • 1
  • 1
Mark Schultheiss
  • 32,614
  • 12
  • 69
  • 100