Thanks, Diogo!

 

Rick

 

From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf 
Of Diogo Neves
Sent: Friday, December 12, 2008 10:24 AM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: What's the correct way to write this code?

 

You can simplify
$('#contentdiv').empty().fadeIn(1000).append(response.login);
To
$('#contentdiv').html(response.login).fadeIn(1000);

Or if you like too short your code you can do all that in:

success: function(response){
    response.login == 'Login Successful' ?  top.location.href = 
'site_manager.cfm'
                                                                 :
$('#contentdiv').html(response.login).fadeIn(1000);
}

On Fri, Dec 12, 2008 at 3:11 PM, Eric Garside <gars...@gmail.com> wrote:


If you haven't already, I'd check out the w3c schools intro to
Javascript.
It's a pretty great way to learn the basic mechanics.

http://www.w3schools.com/JS/default.asp


On Dec 12, 9:51 am, "Rick Faircloth" <r...@whitestonemedia.com> wrote:
> Thanks for the re-write, Hobo!  I like the case syntax.
>
> Also, the tip on the "==" vs "=" is good too.  I'm just hacking
> up code that I find trying to make things work.  I think it's time
> for a basic JS primer!
>
> Thanks again,
>
> Rick
>
> > -----Original Message-----
> > From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
> > Behalf Of Hobo
> > Sent: Friday, December 12, 2008 9:48 AM
> > To: jQuery (English)
> > Subject: [jQuery] Re: What's the correct way to write this code?
>
> > success: function(response){
> >      switch (response.login){
> >           case 'Login Successful':
> >                top.location.href = 'site_manager.cfm';
> >                break;
> >           case 'Login Unsuccessful':
> >                $('#contentdiv').empty().fadeIn(1000).append
> > (response.login);
> >                break;
> >      }
> > }
>
> > Also, be sure to use the "is equal to" operator, which is 2 equal
> > signs, when doing comparisons.
>
> > response.login = "Login Successful";     // Sets response.login to the
> > string "Login Successful"
> > response.login == "Login Successful";  // Tests to see if
> > response.login is equal to the string "Login Successful"
>
> > On Dec 12, 9:07 am, MorningZ <morni...@gmail.com> wrote:
> > > Wow, this is just basic JavaScript syntax
>
> > > if (conditon) {
>
> > > }
> > > else {
> > > }
>
> > > you have
>
> > >  if (response.login = "Login Successful");
>
> > > drop the semi-colon after both your (conditions)
>
> > > On Dec 12, 8:58 am, "Rick Faircloth" <r...@whitestonemedia.com> wrote:
>
> > > > How should this be written?  I can't figure it out.
> > > > I keep getting "syntax error: else"
>
> > > > success: function(response){
>
> > > >      if (response.login = "Login Successful");
> > > >      {top.location.href = "site_manager.cfm"}
>
> > > >      else
>
> > > >      if (response.login == "Login Unsuccessful");
> > > >      {$('#contentdiv').empty().fadeIn(1000).append(response.login)};
>
> > > > }




-- 
Thanks,

Diogo Neves
Web Developer @ SAPO.pt by PrimeIT.pt

Reply via email to