码迷,mamicode.com
首页 > Windows程序 > 详细

ajax-C#

时间:2015-04-30 12:27:53      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:

 $(document).ready(function(){
    $("#month").change(function () {
        var yearSelect = $("#year").find("option:selected").val();
        var monthSelect = $("#month").find("option:selected").val();
        var jsonFormat = "{year:" + yearSelect + ",month:" + monthSelect + "}";
        $.ajaxWebService("GetInfo", jsonFormat, function (data) {
        });
    });
    });

    $.ajaxWebService = function (url, dataparam, datasuccess) {
        $.ajax({
            type: "POST",
            dataType: "json",
            contentType: "application/json",
            url: url,
            data: dataparam,
            success: datasuccess,
            error: function (a, b, c) { }
        });
    }

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace NXT.Areas.Anm.Controllers
{
    public class MonthlyReportController : Controller
    {
        //
        // GET: /Anm/MonthlyReport/

        public ActionResult Index()
        {
            string year = Request["year"];
            string month = Request["month"];
            return View();
        }

        [HttpPost]
        public JsonResult GetInfo(string year,string month)
        {
            //***
            var data = new
            {
                id = 1,
                text = "sdfsdfsdfsdf"
            };
            return Json(data, JsonRequestBehavior.AllowGet);
        }
    }
}

 

ajax-C#

标签:

原文地址:http://www.cnblogs.com/hellowzd/p/4468354.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!