Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to 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.
 
$.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
 
 <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 21-Aug-12 4:49am
dilzz1.2K
Edited 21-Aug-12 6:48am
v5
Comments
Sandip.Nascar at 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 at 21-Aug-12 12:29pm
   
yes, that i meaned, i need to show datas in different areas in a page
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 499
1 Nirav Prabtani 298
2 OriginalGriff 215
3 _Amy 165
4 Abhinav S 160
0 OriginalGriff 7,755
1 Sergey Alexandrovich Kryukov 6,951
2 Maciej Los 3,994
3 Peter Leow 3,698
4 CHill60 2,742


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 21 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100