参考:

http://www.cnblogs.com/kingge/archive/2011/08/04/2127642.html

http://www.cnblogs.com/micromouse/archive/2010/08/14/1799464.html

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization; namespace Entity
{
[DataContract]
public class User
{
[DataMember]
public string Name
{
get;
set;
} [DataMember]
public int Age
{
get;
set;
}
}
}
WebService: using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using Entity; namespace JQuery.Handler
{ [WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class UserService1 : System.Web.Services.WebService
{ [WebMethod]
public string ComplexType(User hero,List<User> users)
{
return hero.Name + " has " + users.Count + " people!";
}
}
}
Html: <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Ajax</title>
<script src="../Scripts/jquery-1.6.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("#btnWeb").click(function () {
$.ajax(
{
type: "post",
url: "../Handler/UserService.asmx/ComplexType",
dataType:"json",
contentType:"application/json",
data: '{"hero": {"Name":"zhoulq","Age":27},"users":[{"Name":"zhangs","Age":22},{"Name":"wangw","Age":26},{"Name":"liuj","Age":25},
{"Name":"luos","Age":}]}',
success: function (data) { $("#web").text(data.d); }
});
});
});
</script>
</head>
<body>
<input id="btnWeb" type="button" value="请求WebService" /><label id="web"></label>
</body>
</html>

Jquery ajax传递复杂参数给WebService的更多相关文章

  1. jQuery ajax传递特殊字符参数(例如+)

    使用jQuery ajax向后台传递参数para=1+1时后台接收到的参数为para=1 1,解决方案是 使用json传递,代码如下. var url = "/test/check" ...

  2. ASP.NET jquery ajax传递参数

    第一种:GET传递 前台 ajax   GET 传递 :即在请求的地址后面加上参数,URL地址长度有显示,安全性低 后台接收:Request.QueryString[“参数名字”]! 例如: func ...

  3. jQuery Ajax 方法调用 Asp.Net WebService 以及调用aspx.cs中方法的详细例子

    一.jQuery Ajax 方法调用 Asp.Net WebService (引自Terry Feng) Html文件 <!DOCTYPE html PUBLIC "-//W3C//D ...

  4. jQuery Ajax方法调用 Asp.Net WebService、WebMethod 的详细实例代码

    将以下html存为ws.aspx <%@ Page Language="C#" AutoEventWireup="true" %> <scri ...

  5. jQuery ajax的traditional参数的作用///////////////////////////////////zzzzzzzzzzz

    jQuery ajax的traditional参数的作用 i33 发布时间: 2013/04/03 10:05 阅读: 9859 收藏: 9 点赞: 1 评论: 0 一般的,可能有些人在一个参数有多个 ...

  6. mvc jquery ajax传递数组null问题

    mvc jquery ajax传递数,  areaIds是个int数组.后台action用list<int>接收.当我想传空值时,先用null传递,结果action收到的AreaIds竟然 ...

  7. jQuery ajax 传递JSON数组到Spring Controller

    jQuery ajax传递单个JSON对象到后台很容易,这里记录的是传递多个JSON对象组成的JSON数组到java 后台,并说明java如何解析JSON数组. 1.js代码 var relation ...

  8. Ajax传递的参数如何在浏览器中查看

    如图当需要在浏览器中知道Ajax传递的参数可以,点击浏览器的右键检查,点击XHR,此时要记得提交带有参数的Ajax页面, 这样才可以显示出来传递的参数

  9. ajax 传递数组参数

    一.ajax 传递数组参数 需要添加: traditional: true, let typeIDArr = [,,,,,]; var that = this; var url = '@Url.Act ...

随机推荐

  1. find命令的使用

    在以.conf结尾的文件里面查找含有aaa字符串的那一行   ( -name后面可以写  "*.*"   即匹配所有的文件 ) find / -name "*.conf& ...

  2. 洛谷P3366最小生成树

    传送门啦 #include <iostream> #include <cstdio> #include <cstring> #include <algorit ...

  3. Unix IPC之Posix信号量实现生产者消费者

    采用多生产者,多消费者模型. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 /**  * 生产者  */ P(nempty); P(mutex); // 写入一个 ...

  4. R语言学习笔记:sort、rank、order、arrange排序函数

    R语言中排序有几个基本函数:sort().rank().order().arrange() 一.总结 sort()函数是对向量进行从小到大的排序 rank()函数返回的是对向量中每个数值对应的秩 or ...

  5. 安装SHARP MX-3618NC PCL6打印机驱动程序

    第一步,  打开MX-CR3_PCL_PS_1302a_ChineseS_Win8Server2012.exe 驱动程序 此驱动支持Win8.Server2012及以下版本的操作系统,同时兼容Win1 ...

  6. dp入门题目

    本文文旨,如题... 转载请注明出处... HDOJ 1176 免费馅饼 http://acm.hdu.edu.cn/showproblem.php?pid=1176 类似数塔,从底往上推,每次都是从 ...

  7. CF 577A 分解因数

    输入一个n 构成一个n*n的表 这个表里的数 第i行j列的值为i*j 问x在这个表里出现了几次 Sample test(s)input10 5output2input6 12output4input5 ...

  8. VS 2015 序列号/密钥/企业版/专业版

    专业版:HMGNV-WCYXV-X7G9W-YCX63-B98R2企业版:HM6NR-QXX7C-DFW2Y-8B82K-WTYJV

  9. CCF CSP 201512-3 画图

    CCF计算机职业资格认证考试题解系列文章为meelo原创,请务必以链接形式注明本文地址 CCF CSP 201512-3 画图 问题描述 用 ASCII 字符来画图是一件有趣的事情,并形成了一门被称为 ...

  10. mysql热数据加载管理

    5.6版本之后,提供了一个新特性来快速预热buffer_pool缓冲池.在my.cnf里面加入几个参数: innodb_buffer_pool_dump_at_shutdown = 1   --在关闭 ...