I am currently using the ScriptManager and whatever comes with it, but I'd like to manage my AJAX in jQuery, because I'm about to start working on something rather important and I want it to be as efficient as possible.

From what it appears, jQuery AJAX fails to reach the server, for a reason unknown to me.

Is there anything else I need to use except for the standard jQuery 1.9.1 library?


HTML && Javascript:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="_Default.aspx.cs" Inherits="jQueryAjax._Default1" %>

<!DOCTYPE html>

  <title>Calling a page method with jQuery</title>
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            // Add the page method call as an onclick handler for the div.
            $("#Result").click(function () {
                    type: "POST",
                    url: "_Default.aspx/GetDate",
                    data: "{}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (msg) {
                        // Replace the div's content with the page method's return.
  <div id="Result">Click here for the time.</div>


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace jQueryAjax
    public partial class _Default1 : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)


        public static string GetDate()
            return DateTime.Now.ToString();

Related posts

Recent Viewed