ASP.NET MVC Load page with AJAX -
i have situation:
a page accordion 2 tabs, 1 has list of paymentmethods, second has summary of order orderlines, amounts , totals (rendered partialview). selecting paymentmethod causes order totals recalculated, costs etc might apply.
what recommended way display new ordersummary after paymentmethod selected, using ajax?
doing ajax call , getting new amounts, orderlines, etc , setting these values using js seems inefficient me. ideal situation if make ajax call selected payement method , call return html can use replace old summary.
is bad render partialview html on server , return using json? best practice situation?
in action method return partialview([view name])
.
then can jquery:
var req = $.ajax({ type:"get",//or "post" or whatever url:"[action method url]" }).success(function(responsedata){ $('targetelement').append($(responsedata));});
where 'targetelement'
selector element want inject content.
you might want $('targetelement').html('');
first before appending response target element.
update
or, better yet, use .load
rick's answer.
Comments
Post a Comment