我有一個模式/對話框有兩個按鈕,「確定」和取消。當我點擊「確定」時,我想將這些數據發送到服務器上的某個功能。我怎樣才能做到這一點?任何人都可以給我一些信息/例子嗎?我相信我將不得不使用「$ .post」,但是又如何將它發送到特定頁面的功能?如何發送數據在後面的代碼中的功能
UPDATED ...仍然無法到達代碼功能。
$('#dialog').dialog({
modal: true,
//autoOpen: false,
bgiframe: false,
closeOnEscape: false,
width: 520,
height: 360,
open: function(event, ui) {
jQuery('.ui-dialog-titlebar-close').hide();
$('#dialog').dialog('option', 'position', 'center'); },
buttons: [
{
text: "Cancel",
click: function() { $(this).dialog("close"); }
},
{
text: "Send",
click: function(){
$.ajax({
type: 'POST',
url: 'test.aspx/GetName',
data: '{name:"' + name + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false
});
}
}],
draggable: false });
return false;
<System.Web.Services.WebMethod()> _
Public Shared Function GetName(ByVal name As String) As String
Return "Hello " & name & Environment.NewLine & "The Current Time is: " & _
DateTime.Now.ToString()
End Function
我想你想達到函數SendEmail?您需要將url更改爲'test.aspx/SendEmail'。 – thomasvdb 2011-06-07 21:03:31
對不起,這是一個錯誤。仍然不能進入「GetName」功能。我的網頁上是否需要某種Ajax設置? – jack 2011-06-07 21:10:14
你可以在async之後添加這個作爲測試:',success:function(data){alert(data.d); }' – thomasvdb 2011-06-07 21:17:37