[jQuery] Re: $.getJSON not returning specified count

2008-12-29 Thread MorningZ

What's the returned JSON look like?




On Dec 29, 6:50 am, JQueryProgrammer jain.ashis...@gmail.com wrote:
 Hi,

 I was trying to get 10 items from the json file. My url in $.getJSON
 looks like:

 $.getJSON(myjsonfile.json?count=10, {}, function(data) {
     $.each(data, function(i, item) {
         alert(item.title);
         alert(i);
     });

 });

 But the above code returns all 20 items from my file. What mistakes am
 I making?


[jQuery] Re: $.getJSON not returning specified count

2008-12-29 Thread JQueryProgrammer

It contains all items from my json file. The file looks like:

[
{title:Title1},
{title:Title2},
{title:Title3},
...
...
{title:Title20}
]

On Dec 29, 4:55 pm, MorningZ morni...@gmail.com wrote:
 What's the returned JSON look like?

 On Dec 29, 6:50 am, JQueryProgrammer jain.ashis...@gmail.com wrote:

  Hi,

  I was trying to get 10 items from the json file. My url in $.getJSON
  looks like:

  $.getJSON(myjsonfile.json?count=10, {}, function(data) {
      $.each(data, function(i, item) {
          alert(item.title);
          alert(i);
      });

  });

  But the above code returns all 20 items from my file. What mistakes am
  I making?


[jQuery] Re: $.getJSON not returning specified count

2008-12-29 Thread Ricardo Tomasi

The count parameter must be implemented server-side, the ajax call has
nothing to do with it. If you want to filter the first 10 items, use
something like this:

$.getJSON(myjsonfile.json, {}, function(data) {
$(data).slice(10).each(function(i, item) {
alert(item.title);
alert(i);
});

});


-ricardo

On Dec 29, 9:58 am, JQueryProgrammer jain.ashis...@gmail.com wrote:
 It contains all items from my json file. The file looks like:

 [
     {title:Title1},
     {title:Title2},
     {title:Title3},
     ...
     ...
     {title:Title20}
 ]

 On Dec 29, 4:55 pm, MorningZ morni...@gmail.com wrote:

  What's the returned JSON look like?

  On Dec 29, 6:50 am, JQueryProgrammer jain.ashis...@gmail.com wrote:

   Hi,

   I was trying to get 10 items from the json file. My url in $.getJSON
   looks like:

   $.getJSON(myjsonfile.json?count=10, {}, function(data) {
       $.each(data, function(i, item) {
           alert(item.title);
           alert(i);
       });

   });

   But the above code returns all 20 items from my file. What mistakes am
   I making?


[jQuery] Re: $.getJSON not returning specified count

2008-12-29 Thread MorningZ

Yeah, as there are 20 items returned over the wire, i'm not sure how
that loop was supposed to know to stop at 10

Time to revisit the server side code of things




On Dec 29, 10:05 am, Ricardo Tomasi ricardob...@gmail.com wrote:
 The count parameter must be implemented server-side, the ajax call has
 nothing to do with it. If you want to filter the first 10 items, use
 something like this:

 $.getJSON(myjsonfile.json, {}, function(data) {
     $(data).slice(10).each(function(i, item) {
         alert(item.title);
         alert(i);
     });

 });

 -ricardo

 On Dec 29, 9:58 am, JQueryProgrammer jain.ashis...@gmail.com wrote:

  It contains all items from my json file. The file looks like:

  [
      {title:Title1},
      {title:Title2},
      {title:Title3},
      ...
      ...
      {title:Title20}
  ]

  On Dec 29, 4:55 pm, MorningZ morni...@gmail.com wrote:

   What's the returned JSON look like?

   On Dec 29, 6:50 am, JQueryProgrammer jain.ashis...@gmail.com wrote:

Hi,

I was trying to get 10 items from the json file. My url in $.getJSON
looks like:

$.getJSON(myjsonfile.json?count=10, {}, function(data) {
    $.each(data, function(i, item) {
        alert(item.title);
        alert(i);
    });

});

But the above code returns all 20 items from my file. What mistakes am
I making?


[jQuery] Re: $.getJSON not returning specified count

2008-12-29 Thread Michael Geary

myjsonfile.json is just a static file on your server? Then of course it will
return the whole thing. If it's a static file, your server doesn't know
anything about that count=10 parameter.

If you want to support parameters like that, you need to write some code on
your server in PHP, Python, Ruby, Perl, or what have you.

-Mike

 From: JQueryProgrammer
 
 It contains all items from my json file. The file looks like:
 
 [
 {title:Title1},
 {title:Title2},
 {title:Title3},
 ...
 ...
 {title:Title20}
 ]
 
 On Dec 29, 4:55 pm, MorningZ morni...@gmail.com wrote:
  What's the returned JSON look like?
 
  On Dec 29, 6:50 am, JQueryProgrammer 
 jain.ashis...@gmail.com wrote:
 
   Hi,
 
   I was trying to get 10 items from the json file. My url 
 in $.getJSON 
   looks like:
 
   $.getJSON(myjsonfile.json?count=10, {}, function(data) {
       $.each(data, function(i, item) {
           alert(item.title);
           alert(i);
       });
 
   });
 
   But the above code returns all 20 items from my file. 
 What mistakes 
   am I making?