Loading ...
Sorry, an error occurred while loading the content.
 

Re: [ydn-javascript] How do I use sendRequest to LocalDataSource with multi-dimensional JSON data?

Expand Messages
  • Satyam
    The first argument to sendRequest is used according to the actual type of the DataSource. When it is a remote DataSource, it will send it to the server and
    Message 1 of 2 , May 29, 2009
      The first argument to sendRequest is used according to the actual type
      of the DataSource. When it is a remote DataSource, it will send it to
      the server and the server will fetch something based on that argument.
      For a LocalDataSource, the argument serves no purpose, since there is no
      implicit rules that could possibly tell it what it should be expected to
      do with it. What you probably need is a FunctionDataSource, where the
      function provided by you will receive the argument to sendRequest and it
      will return the record you expect.

      Satyam


      josiah.fizer escribió:
      > Given a simple data structure like...
      >
      > myData = [
      > {one:"A",two:"B"},
      > {one:"C",two:"D"},
      > {one:"E",two:"F"}
      > ];
      >
      > assigned to a LocalDataSource like...
      >
      > var myDS = new YAHOO.util.LocalDataSource(myData);
      > myDS.responseSchema = {fields : ["one","two"]};
      >
      > and an attempted request to the data like...
      >
      > myDS.sendRequest("A",{success:function(request,response) {
      > alert(response.results[0].two);
      > }});
      >
      > I am getting the full JSON array back in the results rather then the one specific record I'm looking for. How do I go about doing this? Sending a request to the data source for one record in the array?
      >
      >
      >
      > ------------------------------------
      >
      > Yahoo! Groups Links
      >
      >
      >
      > ------------------------------------------------------------------------
      >
      >
      > No virus found in this incoming message.
      > Checked by AVG - www.avg.com
      > Version: 8.5.339 / Virus Database: 270.12.43/2139 - Release Date: 05/28/09 08:10:00
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.