62,047
社区成员
发帖
与我相关
我的任务
分享
1、简单的post请求
$.post("Default.aspx?action=Login", { 'id':1 }, function (data) {
//dosomething
});
//参数1:发送的地址,参数2:发送的参数 因为是post方式 所以格式为json格式 后台取 用request.form
//function(data){} 成功后执行的方法 data为成功后的返回值
2、简单的get请求
$.get('Default.aspx?action=Login&id=1, function (data) {
//dosomething
});
//因为是get方式 参数采用的是地址栏参数的形式如:id=1 其余的如同post
3、WebService方式
$.ajax({
type: "POST", //类型:post get
async: false, //是否异步
url: "Live_RecordTask_Hand.aspx/SaveTask", //URL地址即后台方法地址
data: "{'ID':'1'}", //参数
dataType: "text", //返回类型
contentType: "application/json; charset=utf-8",
success: function (msg) {
//成功执行..
//dosomething
},
error: function (xhr, msg, e) { alert(msg);//出错处理 }
});
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<!--方法1 这样也行 -->
<div>
<table>
<tr>
<td>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true">
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
<!--方法2 这样也行 -->
<table>
<tr>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<td>
<asp:DropDownList ID="DropDownList3" runat="server" AutoPostBack="true">
</asp:DropDownList>
<asp:DropDownList ID="DropDownList4" runat="server">
</asp:DropDownList>
</td>
</ContentTemplate>
</asp:UpdatePanel>
</tr>
</table>
</div>