JavaScript not working online or in safari (locally)

Discussion in 'Web Design and Development' started by tominated, Sep 4, 2007.

  1. tominated macrumors 68000

    tominated

    Joined:
    Jul 7, 2006
    Location:
    Queensland, Australia
    #1
    I have just uploaded my proof of concept (non-working) shopping cart to check loading times, but the javascript (well, jquery javascript. i have gotten quite fond of it) doesn't work. Also, when I was viewing it in safari (locally through MAMP) the javascript didn't work either. can anybody help?

    BTW: linky - http://tominatedsoftware.com/shop
     
  2. elppa macrumors 68040

    elppa

    Joined:
    Nov 26, 2003
    #2
    Seems to works fine.

    You have checked the obvious?
     

    Attached Files:

  3. tominated thread starter macrumors 68000

    tominated

    Joined:
    Jul 7, 2006
    Location:
    Queensland, Australia
  4. elppa macrumors 68040

    elppa

    Joined:
    Nov 26, 2003
    #4


    What is not working exactly.

    I can add things to the cart and clear the whole cart.

    I can't clear individual items though.
     
  5. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #5
    I'd guess that it can't find the local copy of the JQuery code files. Make sure the src attribute is set appropriately.
     
  6. elppa macrumors 68040

    elppa

    Joined:
    Nov 26, 2003
    #6
    For whatever reason, you have to click clear once, then start adding items and it then it works.

    I think this is definitely a problem with your javascript than the browser.


    A quick glance at the page reveals this part is fine.
     
  7. tominated thread starter macrumors 68000

    tominated

    Joined:
    Jul 7, 2006
    Location:
    Queensland, Australia
    #7
    that is what I have implemented (i have to add the single item remove function).

    i don't have a clue why you have to clear first. can a JS expert check out my script to see if it is ok?
     
  8. elppa macrumors 68040

    elppa

    Joined:
    Nov 26, 2003
    #8
    Disclaimer: I have only dabbled in the language and am no expert.

    Change

    Code:
    if (applejuice == ''){
    	var applejuice = '0'
    	var deepsea = '0'
    	var x = '0'
    }
    
    to

    Code:
    if (applejuice == null){
    	var applejuice = '0'
    	var deepsea = '0'
    	var x = '0'
    }
    
    but I would do:

    Code:
    if (applejuice == null){
    	var applejuice = '0'
    }
    
    if (deepsea == null){
    	var deepsea = '0'
    }
    
    if (x == null){
    	var x = '0'
    }
    
    Because otherwise aren't you assuming that if they haven't brought Apple Juice they haven't brought anything else?

    If there is no apple juice cookie the the apple juice variable is set to null, and not an empty string.
     
  9. tominated thread starter macrumors 68000

    tominated

    Joined:
    Jul 7, 2006
    Location:
    Queensland, Australia

Share This Page