Compare Page Revisions
« Older Revision - Back to Page History - Current Revision
itemID
qty
objJSON
AddItemsArgs
$.ajax()
PageName.aspx
MethodName
success
data.d
data
OrderManagerResponse
highlightFlash
var objJSON = { args: { ItemID: itemID, Quantity: qty } }; var encoded = JSON.stringify(objJSON); $.ajax({ type: 'POST', url: 'PageName.aspx/MethodName', contentType: 'application/json; charset=utf-8', data: encoded, processData: false, datatype: 'json', async: false, success: function (data) { if (!data.d.Success) { alert(data.d.Message); } else { $(".ShoppingCartQty").html(data.d.CartItemCount); highlightFlash('.ShoppingCart'); } } });
<%@ Page %>
[WebMethod]
public static
[WebMethod] public static OrderManagerResponse MethodName(AddItemsArgs args) { var result = DoSomething(new Guid(args.ItemID), args.Quantity); return result; }
public class AddItemsArgs { public string ItemID { get; set; } public int Quantity { get; set; } }
public class OrderManagerResponse { public bool Success { get; set; } public string Message { get; set; } public int CartItemCount { get; set; } }
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.