c# - Should I return html or json in a ajax single page checkout -


i want update current asp.net webforms e-commerce site nice one-page checkout , i'm looking "best practice" on how update data. page consist of several parts: cart, user identification, payment options, delivery options etc.

if user changes payment option might result in changes in other parts of page, delivery option becomes unavailable , total cost changes.

do build webservices return full pre-calculated html when user changes on page? or return kind of order-object in json format , update different parts need updating javascript?

the second option seem cleaner me slow normal page? or exist third option?

99.9% of time, json more compact equivalent html: smaller payload means quicker delivery of response. more important reason is:

what if different pages want call webservice: 1 wants display results list while other wants display them table, , third wants put results jggrid? if webservice returns html, 2 of 3 pages can't use service. if webservice returns json, 3 of pages can use easily.

what if, 2 months after deployment, designer/site-owner wants change design table list? if webservice returns json, designer can make necessary changes , easily, affecting 1 or 2 files in deployed system. however, if webservice returns html, need compile, test, , redeploy entire webservice support silly little layout change.

there may times when returning html necessary evil (none can think of off-hand, i'm sure there some). when happens, favor , make sure html webservice building can changed without recompile/re-deploy of entire service. 1 heavy-handed effective way using ajax call aspx page.

update: forgot mention: on slowest javascript engines (internetexplorer), i've found technique (using js parse json , update page accordingly) perform well.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -