<%@ Page Language="C#" AutoEventWireup="true" CodeFile="JQueryTest.aspx.cs" Inherits="自定义滚动条_JQueryTest" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title></title>
<script src="jquery-1.8.3.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$("#btnOK").click(function() {
$.ajax({
type: "Post",
url: "JQueryTest.aspx/SayHello",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
alert(data.d);
},
error: function(err) {
alert(err);
}
});
return false;
});
$("#btnOK0").click(function() {
$.ajax({
type: "Post",
url: "JQueryTest.aspx/GetStr",
data: "{'str':'我是','str2':'XXX'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
alert(data.d);
},
error: function(err) {
alert(err);
}
});
return false;
});
$("#btnOK1").click(function() {
$.ajax({
type: "Post",
url: "JQueryTest.aspx/GetArray",
data: "{}",
contentType: "application/json; chartset=utf-8",
dataType: "json",
success: function(data) {
$("#list").html("");
$(data.d).each(function() {
$("#list").append("<li>" + this + "</li>");
});
alert(data.d);
},
error: function(err) {
alert(err);
}
});
return false;
});
$("#btnOK2").click(function() {
$.ajax({
type: "Post",
url: "JQueryTest.aspx/GetHash",
data: "{'key':'haha','value':'哈哈!'}",
contentType: "application/json: charset=utf-8",
dataType: "json",
success: function(data) {
alert("key:haha==>" + data.d["haha"] + "/n key:www==>" + data.d["www"]);
},
error: function(err) {
alert(err + "err");
}
});
return false;
});
$("#btnOK3").click(function() {
$.ajax({
url: "XMLTest.xml",
dataType: 'xml',
success: function(xml) {
$("#list1").html("");
$(xml).find("data>item").each(function() {
$("#list1").append("<li>id:" + $(this).find("id").text() + "</li>");
$("#list1").append("<li>name:" + $(this).find("name").text() + "</li>");
})
},
error: function(result, status) {
alert(status);
}
});
return false;
});
}); </script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="btnOK" type="button" value="button" />
<input id="btnOK0" type="button" value="button" />
<input id="btnOK1" type="button" value="button" />
<input id="btnOK2" type="button" value="button" />
<input id="btnOK3" type="button" value="button" />
<ul id="list"></ul>
<ul id="list1"></ul>
</div>
</form>
</body>
</html>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Script.Services;
using System.Web.Services;
using System.Collections; public partial class 自定义滚动条_JQueryTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ } [WebMethod]
public static string SayHello()
{
return "Hello Ajax";
} [WebMethod]
public static string GetStr(string str, string str2)
{
return str + str2;
} [WebMethod]
public static List<string> GetArray()
{
List<string> li = new List<string>();
for (int i = ; i < ; i++)
{
li.Add(i + "");
}
return li;
} [WebMethod]
public static Hashtable GetHash(string key, string value)
{
Hashtable hs = new Hashtable();
hs.Add("www", "yahooo");
hs.Add(key, value);
return hs;
}
}

Jqeury ajax 调用C#的后台程序的更多相关文章

  1. ajax 调用asp.net后台方法

    ajax 调用asp.net后台方法  这种做法有好几种,如调用xx.asxh 页面,或者直接调用xx.aspx也面,在page_Load中进行一些判断然后调用后面的其他方法, 或者你可以直接调用we ...

  2. AJAX不能访问MVC后台程序的问题

    AJAX不能访问后台的MVC有可能是MVC的后台程序加入了身份验证[Authorize]标记,这样前台的AJAX虽然结果显示的是4和200但是responsetext的值可以看到是返回了一个配置文件中 ...

  3. .Net中jQuery.ajax()调用asp.net后台方法 总结

    利用JQuery的$.ajax()调用.Net后台方法有多种方式, 不多说了  直接上代码 前台代码 <script type="text/javascript"> $ ...

  4. JQuery Ajax调用asp.net后台方法

    利用JQuery的$.ajax()可以很方便的调用asp.net的后台方法. 先来个简单的实例热热身吧. 1.无参数的方法调用 asp.net code: using System.Web.Scrip ...

  5. jQuery.ajax()调用asp.net后台方法

    利用JQuery的$.ajax()可以很方便的调用asp.net的后台方法.介意方法名不要重名 建一个WebFormAjax名aspx文件 CS <%@ Page Language=" ...

  6. Ajax调用asp.net后台代码

    后台代码: [WebMethod] public static string CreateDate(string name,string age) { return "姓名:"+n ...

  7. jQuery.ajax()调用asp.net后台方法(非常重要)

    http://www.cnblogs.com/zxhoo/archive/2011/01/30/1947752.html 用JQuery的$.ajax()可以很方便的调用asp.net的后台方法. 先 ...

  8. js数字转金额,ajax调用接口,后台返回html(完整页面),打开新窗口并写入html

    一.转换成金额形式 function toMoney(num){ if(num){ if(isNaN(num)) { alert("金额中含有不能识别的字符"); return; ...

  9. Ajax——ajax调用数据总结

    在做人事系统加入批量改动的功能中,须要将前台中的数据传给后台.后台并运行一系列的操作. 通过查询和学习了解到能够通过ajax将值传入到后台,并在后台对数据进行操作. 说的简单点.就是ajax调用后台的 ...

随机推荐

  1. WebMagic 爬虫框架

    官方网站[http://webmagic.io/](http://webmagic.io/) >webmagic是一个开源的Java垂直爬虫框架,目标是简化爬虫的开发流程,让开发者专注于逻辑功能 ...

  2. redis 简单命令操作

    一.概述: 在该系列的前几篇博客中,主要讲述的是与Redis数据类型相关的命令,如String.List.Set.Hashes和Sorted-Set.这些命令都具有一个共同点,即所有的操作都是针对与K ...

  3. C++通过HTTP请求Get或Post方式请求Json数据(转)

    原文网址:https://www.cnblogs.com/shike8080/articles/6549339.html #pragma once#include <iostream>#i ...

  4. 【Python】__slots__ 、@property、多重继承、定制类、枚举类、元类

    __slots__ @property 多重继承 定制类 枚举类 元类 [使用__slots__] 1.动态语言的一个特点就是允许给实例绑定任意的方法和变量,而静态语言(例如Java)必须事先将属性方 ...

  5. Django----Request对象&Response对象

    Django 使用Request 对象和Response 对象在系统间传递状态. HttpRequest 对象: Request.body:一个字节字符串,表示原始HTTP 请求的正文.它对于处理非H ...

  6. JavScript 日期格式化

    JavScript 日期格式化 //日期格式化 function formatDate(date,fmt) { if(date == null || typeof (date) == undefine ...

  7. xxxx interview

    1. 什么数据库,做了什么优化? 回答mysql innodb与myisam区别,根据业务选择引擎.事务,行级锁,全文检索,二级索引. 存储:myisam数据和索引分开存储.innodb数据和索引存储 ...

  8. linux系统调用是通过软中断实现的吗

    软中断是利用硬件中断的概念,用软件方式进行模拟,实现宏观上的异步执行效果.很多情况下,软中断和信号有些类似,同时,软中断又是和硬中断相对应的,硬中断是外部设备对CPU的中断,软中断通常是硬中断服务程序 ...

  9. 快用Visual Studio(二)- 界面,功能区与命令面板

    Layout Editing Explorer Saving Searching Command Palette File Navigation File and Folder Based Files ...

  10. SSM到Spring Boot-从零开发校园商铺平台

    第1章 开发准备 本章包含课程介绍,同时讲解开发网站所需要准备的事情,并且带领大家从零开始搭建一个Maven Web. 1-1 课程导学 1-2 开发准备 第2章 项目设计和框架搭建 本章主要先带领大 ...