如何从ASP.NET检索JSONdata并将其发送到jQuery的? (实施FullCalendar) [英] How can I retrieve JSONdata from ASP.NET and send it to jQuery? (implementing FullCalendar)

查看:93
本文介绍了如何从ASP.NET检索JSONdata并将其发送到jQuery的? (实施FullCalendar)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让JSON数据到使用ASP.NET(不MVC)一个jQuery变量:

I'm trying to get JSON-data into a jQuery variable using ASP.NET (not MVC):

$(document).ready(function () {
    $('#calendar').fullCalendar({
        events: GetEvents(start, end) //This line is invalid
    }
}

在MVC中,它可能只是事件:/日历/ GetEvents /,这将调用CalendarController的GetEvents() - 方法

In MVC, it could just be events: "/Calendar/GetEvents/", which would call the CalendarController's GetEvents()-method.

但是,因为我不使用MVC,我开始跟随<一个href=\"http://decoding.word$p$pss.com/2008/11/14/aspnet-how-to-call-a-server-side-method-from-client-side-javascript/\"相对=nofollow>本指南尝试从客户端调用服务器端方法。

But since I'm not using MVC I started following this guide to try calling server-side methods from the client.

在第二个步骤它告诉我,我在为了做到这一点,以创建一个静态方法:

In the second step it tells me that I have to create a static method in order to do this:

[System.Web.Services.WebMethod]
public static string Message()
{
    return "Hello from the server-side World!";
}

不过,我需要能够访问像非静态变量会议[] 的方法里面,所以我实在看不出这种做法将如何工作。

But I need to be able to access non-static variables like Session[] inside the method, so I can't really see how this approach would work.

有没有得到来自不涉及直接做服务器端调用的aspx.cs法提取JSON数据更好的方法?还是有我使用,我是不知道的?会话的方式

推荐答案

private static HttpSessionState MySession
{
  get
  {
    return HttpContext.Current.Session;
  }

  set
  {
    return HttpContext.Current.Session = value;
  }
}

这篇关于如何从ASP.NET检索JSONdata并将其发送到jQuery的? (实施FullCalendar)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆