我有這個代碼從here。 頁面礦脈我喜歡送2 VAL「名」和「城市」如何在jQuery中發送數組並獲得在asp.net c#
這是claint側在服務器端Default.aspx.cs我希望得到的js代碼
$(document).ready(function() {
$.post("Default.aspx",
{
name: "Donald Duck",
city: "Duckburg"
},
function (data, status) {
alert("Data: " + data + "\nStatus: " + status);
});
});
2 VAL「名」和「城市」
這是服務端代碼
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string id = Request.QueryString["name"];
var status = Request.Form["city"];
string fname = Request.Form["name"];
string city = Request.Form["city"];
}
}
whay不工作???
什麼是不工作?您是否嘗試過觀看瀏覽器開發工具的請求?您是否嘗試過在服務器上進行調試以查看這些變量值是什麼? –
你需要在你的表單中創建一個web方法並調用它:http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/ –
Joe Enos在調試all val時null –