[jQuery] Re: I'll Donate $20USD to Jquery if you can teach me how to do this

2009-05-18 Thread KrushRadio - Doc

I'll have to check that out... seeing i can eventually craft the data
however i want to when it comes out..

But note to self and completly off conversation... Based on that
example, I could use jquery to parse LUA that comes from World Of
Warcraft   The dataformat is very very similar.

On May 18, 9:33 am, "CarComplaints.com"  wrote:
> I'll second the JSON suggestion. Assuming from your XML code example
> that you're only ever going to have day/show nodes, here's the JSON:
>
> {
>   'Monday' : [
>     { time : "0800-1000", dj : "mc funk", name : "nonstop music" },
>     { time : "1000-1200", dj : "mc rap", name : "nonstop music" }
>   ],
>   'Tuesday' : [
>     { time : "0800-1000", dj : "mc stoner", name : "nonstop music" },
>     { time : "1000-1200", dj : "mc ambient", name : "nonstop music" }
>   ]
>
> }
>
> The Javascript code looks like
> $(function() {
>   $.ajax({
>     url:'test.php',
>     dataType:'json',
>     success:function(schedule) {
>       for (var day in schedule) {
>         $('body').append('' + day + '');
>         for (var i = 0; i < schedule[day].length; i++) {
>           var s = schedule[day][i];
>           $('body').append('' + s.time + '' + s.dj + ''
> + s.name + '');
>         }
>       }
>     },
>     error:function(r,t,e) { alert(t); }
>   });
>
> });
>
> Hope that helps .. JSON is about as lightweight as it gets.
>
> -Wickhttp://www.CarComplaints.com
>
> On May 18, 3:21 am, Josh Powell  wrote:
>
>
>
> > If you aren't forced to use XML, look at trying JSON instead.  It is a
> > MUCH friendlier format for passing information around.- Hide quoted text -
>
> - Show quoted text -


[jQuery] Re: I'll Donate $20USD to Jquery if you can teach me how to do this

2009-05-18 Thread CarComplaints.com


I'll second the JSON suggestion. Assuming from your XML code example
that you're only ever going to have day/show nodes, here's the JSON:

{
  'Monday' : [
{ time : "0800-1000", dj : "mc funk", name : "nonstop music" },
{ time : "1000-1200", dj : "mc rap", name : "nonstop music" }
  ],
  'Tuesday' : [
{ time : "0800-1000", dj : "mc stoner", name : "nonstop music" },
{ time : "1000-1200", dj : "mc ambient", name : "nonstop music" }
  ]
}

The Javascript code looks like
$(function() {
  $.ajax({
url:'test.php',
dataType:'json',
success:function(schedule) {
  for (var day in schedule) {
$('body').append('' + day + '');
for (var i = 0; i < schedule[day].length; i++) {
  var s = schedule[day][i];
  $('body').append('' + s.time + '' + s.dj + ''
+ s.name + '');
}
  }
},
error:function(r,t,e) { alert(t); }
  });
});

Hope that helps .. JSON is about as lightweight as it gets.

-Wick
http://www.CarComplaints.com


On May 18, 3:21 am, Josh Powell  wrote:
> If you aren't forced to use XML, look at trying JSON instead.  It is a
> MUCH friendlier format for passing information around.
>


[jQuery] Re: I'll Donate $20USD to Jquery if you can teach me how to do this

2009-05-18 Thread CarComplaints.com

jQuery selectors take an optional 2nd parameter to provide a search
context (object to search through). Pretty minor but it reduces the
code nicely... you can get rid of the 3 find()'s.

  var time = $('time',this).text();
  var dj = $('dj',this).text();
  var showname = $('showname',this).text();

Docs about it are here:
http://docs.jquery.com/Core/jQuery#expressioncontext

-Wick
http://www.CarComplaints.com


On May 17, 8:43 pm, "comslash.com"  wrote:
> $(function(){
>
>                         $.ajax({
>                                 type: "GET",
>                                 url: "test.xml",
>                                 dataType: "xml",
>                                 success: function(data){
>                                  $('day[name=Monday]>show', 
> data).each(function(){
>                                                         time     = 
> $(this).find('time').text();
>                                                         dj               = 
> $(this).find('dj').text();
>                                                         showname 
> =$(this).find('showname').text();
>
>                                                         $('body').append(time 
> + '' + dj + '' + showname +
> '');
>                                          });
>                                 }
>                         });
>
>                 });

[jQuery] Re: I'll Donate $20USD to Jquery if you can teach me how to do this

2009-05-18 Thread donb

And when size is important, smaller too.

On May 18, 3:21 am, Josh Powell  wrote:
> If you aren't forced to use XML, look at trying JSON instead.  It is a
> MUCH friendlier format for passing information around.
>
> On May 17, 11:09 pm, KrushRadio - Doc  wrote:
>
> > Paypal Transaction ID: 8PY233604R986225R :D
>
> > Thanks for your help.
>
> > Actually, there were 2 parts that I didn't get.. one was the CSS
> > selector syntax and how it needed to be formed inside of the initial
> > grab..
>
> > Thats the learning curve.  the way that 'day[name=Monday]show' didn't
> > make any sense to me.  in xpath i'd have to use the /day
> > [...@name='monday']/show  would have made more sense... The lack of
> > quotes would have thrown me the most.  i probably would have chained
> > the show at the end of it, in another each function.
>
> > So, basically, the initial dataset definition can be in the first
> > part, I don't have to chain the find(day and attribute).find(show,
> > data).each(function(){ do stuff here}  which was the original track i
> > was going down.
>
> > Thanks so much again... this part has been haunting me.
>
> > ~Doc
>
> > On May 17, 8:20 pm, deltaf  wrote:
>
> > > And now for the "teaching" part of the request...
>
> > > KrushRadio, the crucial part that I believe you wanted to be taught
> > > about is:
> > >  $('day[name=Monday]>show', data)
>
> > > If you're familiar with CSS selector syntax, that's a great head-
> > > start.The full details can be found athttp://docs.jquery.com/Selectors
>
> > > To break it down for you, the selector includes " elements that
> > > are children of  elements with name attributes equal to
> > > 'Monday'". All of the matched results are put into an array of
> > > elements which are iterated with .each().
>
> > > Hope we've helped earn jQuery that donation!
>
> > >  - jb
>
> > > On May 17, 8:43 pm, "comslash.com"  wrote:
>
> > > > $(function(){
>
> > > >                         $.ajax({
> > > >                                 type: "GET",
> > > >                                 url: "test.xml",
> > > >                                 dataType: "xml",
> > > >                                 success: function(data){
> > > >                                  $('day[name=Monday]>show', 
> > > > data).each(function(){
> > > >                                                         time     = 
> > > > $(this).find('time').text();
> > > >                                                         dj              
> > > >  = $(this).find('dj').text();
> > > >                                                         showname 
> > > > =$(this).find('showname').text();
>
> > > >                                                         
> > > > $('body').append(time + '' + dj + '' + showname +
> > > > '');
> > > >                                          });
> > > >                                 }
> > > >                         });
>
> > > >                 });- Hide quoted text -
>
> > > - Show quoted text -


[jQuery] Re: I'll Donate $20USD to Jquery if you can teach me how to do this

2009-05-18 Thread Josh Powell

If you aren't forced to use XML, look at trying JSON instead.  It is a
MUCH friendlier format for passing information around.

On May 17, 11:09 pm, KrushRadio - Doc  wrote:
> Paypal Transaction ID: 8PY233604R986225R :D
>
> Thanks for your help.
>
> Actually, there were 2 parts that I didn't get.. one was the CSS
> selector syntax and how it needed to be formed inside of the initial
> grab..
>
> Thats the learning curve.  the way that 'day[name=Monday]show' didn't
> make any sense to me.  in xpath i'd have to use the /day
> [...@name='monday']/show  would have made more sense... The lack of
> quotes would have thrown me the most.  i probably would have chained
> the show at the end of it, in another each function.
>
> So, basically, the initial dataset definition can be in the first
> part, I don't have to chain the find(day and attribute).find(show,
> data).each(function(){ do stuff here}  which was the original track i
> was going down.
>
> Thanks so much again... this part has been haunting me.
>
> ~Doc
>
> On May 17, 8:20 pm, deltaf  wrote:
>
> > And now for the "teaching" part of the request...
>
> > KrushRadio, the crucial part that I believe you wanted to be taught
> > about is:
> >  $('day[name=Monday]>show', data)
>
> > If you're familiar with CSS selector syntax, that's a great head-
> > start.The full details can be found athttp://docs.jquery.com/Selectors
>
> > To break it down for you, the selector includes " elements that
> > are children of  elements with name attributes equal to
> > 'Monday'". All of the matched results are put into an array of
> > elements which are iterated with .each().
>
> > Hope we've helped earn jQuery that donation!
>
> >  - jb
>
> > On May 17, 8:43 pm, "comslash.com"  wrote:
>
> > > $(function(){
>
> > >                         $.ajax({
> > >                                 type: "GET",
> > >                                 url: "test.xml",
> > >                                 dataType: "xml",
> > >                                 success: function(data){
> > >                                  $('day[name=Monday]>show', 
> > > data).each(function(){
> > >                                                         time     = 
> > > $(this).find('time').text();
> > >                                                         dj               
> > > = $(this).find('dj').text();
> > >                                                         showname 
> > > =$(this).find('showname').text();
>
> > >                                                         
> > > $('body').append(time + '' + dj + '' + showname +
> > > '');
> > >                                          });
> > >                                 }
> > >                         });
>
> > >                 });- Hide quoted text -
>
> > - Show quoted text -


[jQuery] Re: I'll Donate $20USD to Jquery if you can teach me how to do this

2009-05-17 Thread KrushRadio - Doc

Paypal Transaction ID: 8PY233604R986225R :D

Thanks for your help.

Actually, there were 2 parts that I didn't get.. one was the CSS
selector syntax and how it needed to be formed inside of the initial
grab..

Thats the learning curve.  the way that 'day[name=Monday]show' didn't
make any sense to me.  in xpath i'd have to use the /day
[...@name='monday']/show  would have made more sense... The lack of
quotes would have thrown me the most.  i probably would have chained
the show at the end of it, in another each function.

So, basically, the initial dataset definition can be in the first
part, I don't have to chain the find(day and attribute).find(show,
data).each(function(){ do stuff here}  which was the original track i
was going down.

Thanks so much again... this part has been haunting me.

~Doc

On May 17, 8:20 pm, deltaf  wrote:
> And now for the "teaching" part of the request...
>
> KrushRadio, the crucial part that I believe you wanted to be taught
> about is:
>  $('day[name=Monday]>show', data)
>
> If you're familiar with CSS selector syntax, that's a great head-
> start.The full details can be found athttp://docs.jquery.com/Selectors
>
> To break it down for you, the selector includes " elements that
> are children of  elements with name attributes equal to
> 'Monday'". All of the matched results are put into an array of
> elements which are iterated with .each().
>
> Hope we've helped earn jQuery that donation!
>
>  - jb
>
> On May 17, 8:43 pm, "comslash.com"  wrote:
>
>
>
> > $(function(){
>
> >                         $.ajax({
> >                                 type: "GET",
> >                                 url: "test.xml",
> >                                 dataType: "xml",
> >                                 success: function(data){
> >                                  $('day[name=Monday]>show', 
> > data).each(function(){
> >                                                         time     = 
> > $(this).find('time').text();
> >                                                         dj               = 
> > $(this).find('dj').text();
> >                                                         showname 
> > =$(this).find('showname').text();
>
> >                                                         
> > $('body').append(time + '' + dj + '' + showname +
> > '');
> >                                          });
> >                                 }
> >                         });
>
> >                 });- Hide quoted text -
>
> - Show quoted text -


[jQuery] Re: I'll Donate $20USD to Jquery if you can teach me how to do this

2009-05-17 Thread KrushRadio - Doc

Paypal Transaction ID: 8PY233604R986225R :D

Thanks for your help.

Actually, there were 2 parts that I didn't get.. one was the CSS
selector syntax and how it needed to be formed inside of the initial
grab..

Thats the learning curve.  the way that 'day[name=Monday]show' didn't
make any sense to me.  in xpath i'd have to use the /day
[...@name='monday']/show  would have made more sense... The lack of
quotes would have thrown me the most.  i probably would have chained
the show at the end of it, in another each function.

So, basically, the initial dataset definition can be in the first
part, I don't have to chain the find(day and attribute).find(show,
data).each(function(){ do stuff here}  which was the original track i
was going down.

Thanks so much again... this part has been haunting me.

~Doc

On May 17, 8:20 pm, deltaf  wrote:
> And now for the "teaching" part of the request...
>
> KrushRadio, the crucial part that I believe you wanted to be taught
> about is:
>  $('day[name=Monday]>show', data)
>
> If you're familiar with CSS selector syntax, that's a great head-
> start.The full details can be found athttp://docs.jquery.com/Selectors
>
> To break it down for you, the selector includes " elements that
> are children of  elements with name attributes equal to
> 'Monday'". All of the matched results are put into an array of
> elements which are iterated with .each().
>
> Hope we've helped earn jQuery that donation!
>
>  - jb
>
> On May 17, 8:43 pm, "comslash.com"  wrote:
>
>
>
> > $(function(){
>
> >                         $.ajax({
> >                                 type: "GET",
> >                                 url: "test.xml",
> >                                 dataType: "xml",
> >                                 success: function(data){
> >                                  $('day[name=Monday]>show', 
> > data).each(function(){
> >                                                         time     = 
> > $(this).find('time').text();
> >                                                         dj               = 
> > $(this).find('dj').text();
> >                                                         showname 
> > =$(this).find('showname').text();
>
> >                                                         
> > $('body').append(time + '' + dj + '' + showname +
> > '');
> >                                          });
> >                                 }
> >                         });
>
> >                 });- Hide quoted text -
>
> - Show quoted text -


[jQuery] Re: I'll Donate $20USD to Jquery if you can teach me how to do this

2009-05-17 Thread deltaf

And now for the "teaching" part of the request...

KrushRadio, the crucial part that I believe you wanted to be taught
about is:
 $('day[name=Monday]>show', data)

If you're familiar with CSS selector syntax, that's a great head-
start.The full details can be found at http://docs.jquery.com/Selectors

To break it down for you, the selector includes " elements that
are children of  elements with name attributes equal to
'Monday'". All of the matched results are put into an array of
elements which are iterated with .each().

Hope we've helped earn jQuery that donation!

 - jb


On May 17, 8:43 pm, "comslash.com"  wrote:
> $(function(){
>
>                         $.ajax({
>                                 type: "GET",
>                                 url: "test.xml",
>                                 dataType: "xml",
>                                 success: function(data){
>                                  $('day[name=Monday]>show', 
> data).each(function(){
>                                                         time     = 
> $(this).find('time').text();
>                                                         dj               = 
> $(this).find('dj').text();
>                                                         showname 
> =$(this).find('showname').text();
>
>                                                         $('body').append(time 
> + '' + dj + '' + showname +
> '');
>                                          });
>                                 }
>                         });
>
>                 });


[jQuery] Re: I'll Donate $20USD to Jquery if you can teach me how to do this

2009-05-17 Thread comslash.com

donb because passing xml can be much smaller then passing the data
with html wrapped around it.

On May 17, 6:41 pm, donb  wrote:
> I can't figure out why you want to pass data in a non-usable format so
> you have to whack away at it with lots of code to turn it into what
> you need. Why not generate what you need to start with, so the task is
> reduced to simply requesting a chunk of html and inserting it into the
> DOM.
>
> On May 17, 3:09 pm, KrushRadio - Doc  wrote:
>
> > Hey Guys/Gals,
>
> > I have been able to use JQuery in the past, for simple things, and
> > after much hacking around, i have been able to get it to work.  I want
> > to embrace this technology, but I can't get past the examples.
> > They're very basic, and I can't wrap my head around how to move them
> > into real world scenarios.  I'm a dev, but not a javascript dev.  I
> > mean, i know how to do this in Javascript, using xpath and filters,
> > but i really want to use JQuery as the engine, to keep it consistant
> > with the rest of the project.
>
> > using Javascript, I would just do a
> > var tDay = Document.DOM.selectSinglenode("/schedule/day
> > [...@name="Monday"])
> > and then loop thru there and list out everything into my table, and
> > display the html
>
> > But i want to do this using JQuery.
>
> > Here is the sample xml:
>
> > 
> >         
> >                 
> >                         0800-1000
> >                         nonstop rock
> >                         nonstop music
> >                 
> >                 
> >                         1000-1200
> >                         nonstop rock
> >                         nonstop music
> >                 
> >         
> >         
> >                 
> >                         0800-1000
> >                         nonstop rock
> >                         nonstop music
> >                 
> >                 
> >                         1000-1200
> >                         nonstop rock
> >                         nonstop music
> >                 
> >                 
> >                         1200-1400
> >                         nonstop rock
> >                         nonstop music
> >                 
> >         
> > 
>
> > So, here's what i want to see... I can understand the code when i see
> > it, but i'd like to see the specific code.
> > So, the first part would be to isolate the attribute of "name" for the
> > "day" element,
> > Then how it loops thru each 'show' element, and find the 'time', the
> > 'dj' and the 'showname'.  once i get that, i can add them together
> > with the html and post it to the .append code.  I just don't
> > understand how the daisy chain would work from here.
>
> > Thanks for you help.  The application on this, will be end up being an
> > ajax app, where i pass it the day of the week (monday/tuesday/
> > wednesday) and it will display the shows for that day in order of
> > time.
>
> > ~Doc


[jQuery] Re: I'll Donate $20USD to Jquery if you can teach me how to do this

2009-05-17 Thread comslash.com

$(function(){

$.ajax({
type: "GET",
url: "test.xml",
dataType: "xml",
success: function(data){
 $('day[name=Monday]>show', 
data).each(function(){
time = 
$(this).find('time').text();
dj   = 
$(this).find('dj').text();
showname 
=$(this).find('showname').text();

$('body').append(time + 
'' + dj + '' + showname +
'');
 });
}
});


});


[jQuery] Re: I'll Donate $20USD to Jquery if you can teach me how to do this

2009-05-17 Thread comslash.com

$(function(){

$.ajax({
type: "GET",
url: "test.xml",
dataType: "xml",
success: function(data){
 $('day[name=Monday]>show', 
data).each(function(){
$(this).each(function(){
time   = 
$(this).find('time').text();
dj = 
$(this).find('dj').text();
showname  
=$(this).find('showname').text();

$('body').append(time + 
'' + dj + '' + showname +
'');
});
 });
}
});


});


[jQuery] Re: I'll Donate $20USD to Jquery if you can teach me how to do this

2009-05-17 Thread donb

I can't figure out why you want to pass data in a non-usable format so
you have to whack away at it with lots of code to turn it into what
you need. Why not generate what you need to start with, so the task is
reduced to simply requesting a chunk of html and inserting it into the
DOM.

On May 17, 3:09 pm, KrushRadio - Doc  wrote:
> Hey Guys/Gals,
>
> I have been able to use JQuery in the past, for simple things, and
> after much hacking around, i have been able to get it to work.  I want
> to embrace this technology, but I can't get past the examples.
> They're very basic, and I can't wrap my head around how to move them
> into real world scenarios.  I'm a dev, but not a javascript dev.  I
> mean, i know how to do this in Javascript, using xpath and filters,
> but i really want to use JQuery as the engine, to keep it consistant
> with the rest of the project.
>
> using Javascript, I would just do a
> var tDay = Document.DOM.selectSinglenode("/schedule/day
> [...@name="Monday"])
> and then loop thru there and list out everything into my table, and
> display the html
>
> But i want to do this using JQuery.
>
> Here is the sample xml:
>
> 
>         
>                 
>                         0800-1000
>                         nonstop rock
>                         nonstop music
>                 
>                 
>                         1000-1200
>                         nonstop rock
>                         nonstop music
>                 
>         
>         
>                 
>                         0800-1000
>                         nonstop rock
>                         nonstop music
>                 
>                 
>                         1000-1200
>                         nonstop rock
>                         nonstop music
>                 
>                 
>                         1200-1400
>                         nonstop rock
>                         nonstop music
>                 
>         
> 
>
> So, here's what i want to see... I can understand the code when i see
> it, but i'd like to see the specific code.
> So, the first part would be to isolate the attribute of "name" for the
> "day" element,
> Then how it loops thru each 'show' element, and find the 'time', the
> 'dj' and the 'showname'.  once i get that, i can add them together
> with the html and post it to the .append code.  I just don't
> understand how the daisy chain would work from here.
>
> Thanks for you help.  The application on this, will be end up being an
> ajax app, where i pass it the day of the week (monday/tuesday/
> wednesday) and it will display the shows for that day in order of
> time.
>
> ~Doc