Home > Web Front-end > JS Tutorial > jquery asynchronously calls page background method‏(asp.net)_jquery

jquery asynchronously calls page background method‏(asp.net)_jquery

WBOY
Release: 2016-05-16 18:09:54
Original
1255 people have browsed it
复制代码 代码如下:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JqueryCSMethodForm.aspx.cs" Inherits="JQuerWeb.JqueryCSMethodForm" %>


















CS代码:
复制代码 代码如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
namespace JQuerWeb
{
public partial class JqueryCSMethodForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static String GetNowDate()
{
return "[{"nowtime":"" DateTime.Now.ToShortDateString() ""}]";
}
[WebMethod]
public static String GetOneDayLate(Int32 days)
{
return "[{"nowtime":"" DateTime.Now.AddDays(days).ToShortDateString() ""}]";
}
}
}

注意点:
(1) url的填写格式 url "/method name"
(2) contentType: "application/json; charset=utf-8", 这个必须要有
(3) 返回数据的类型为json
(4) data:"{days:1}",参数的传递
(5) 后台的方法必须是public static 而且还要有 [WebMethod]特性修饰
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template