Click here to Skip to main content
15,867,330 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
HI,

am doing an asp.net project and am using jquery ajax for post the data and retrive it.

Here is the below code.

JavaScript
$.ajax(
{
   type: "POST",
   url: "../../GeneralService.asmx/ShowBooked_Items",
   dataType: "json",
   data: JSON.stringify({ "Item_ID": $(this).attr('id') }),
   contentType: "application/json; charset=utf-8",
   success: function (json) {
      var output = $('#MyTemplate').parseTemplate(json);
      $('#MyTemplateOutput').html(output);
   }
});


and here is the HTML Code

HTML
 <div id="MyTemplateOutput">
   </div>
   <script id="MyTemplate" type="text/html">
   <table id="ContentPlaceHolder1_dlSub_Items" cellspacing="0" style="width:100%;border-collapse:collapse;">
   <#
      for(var i=0; i < d.length; i++)     
      {      
         var cust = d[i]; 
   #>
   // here is the code for Displaying dynamic datas.
   <# 
      }
   #>

</script>


This code is working Fine. Here Here i have posted to 'GeneralService.asmx' and there i have used Generic List for taking the datas and returned.

And my question is When i have used this code then it is working fine.
I need to print datas in different areas of a page.

How i can do it. Please Help me.


Thanks

Dileep
Posted
Updated 21-Aug-12 6:48am
v5
Comments
Sandip.Nascar 21-Aug-12 12:26pm    
Didn't get you actually. By different locations, did you mean to show data in different areas of the page. If yes you can place display controls in different areas as per your requirement and render with proper data.
dilzz 21-Aug-12 12:29pm    
yes, that i meaned, i need to show datas in different areas in a page

Well, as per your comment dilzz,
The simplest approach is to design the page with different divs.



so on..

Now in ajax call "success", you get the data
Iterate the data to get specific value and assign to div innerhtml

$('#div_1').html(val1);
$('#div_1').html(val2);
so on...


Hope this helps.
cheers
 
Share this answer
 
If you want the data shown in different areas, you need to write cod eto show it, and if your AJAX call updates it, update them all.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900