0

I written this script, to add JavaScript functionality to my online shop, the script works fine with Firefox and Chrome, but will not run on ie, and i am not sure why?

i am using jQuery(function( $ ){ instead of .ready due to script conflicts, i have tested the script using .ready and it still does not work with ie.

if anyone has an ideas they would be much appreciated.

jQuery(function( $ ){

setInterval(function(){ updatecart();  },8000);

   $('.addtobag').on('click', function(){
       event.preventDefault();
       var postdata = new Object();

       var action = $(this).closest('form').attr('action');

      $(':input',$(this).closest('form')).each(function(evt){

        var L = $(this).attr('name')
        postdata[L] = $(this).val();

      });


       $.post(action, postdata);

       generate('success'); //display banner
        updatecart();   //update cart

            });

    var postdata = new Object();

    postdata['basket'] = phpbasket;



     function updatecart() {

      $.post("/get_cart_details.php", postdata, function (data) {
                      var obj = $.parseJSON(data);
                           $('#qty_js').text(obj.items_qty);
                           $('#amt_js').text(obj.items_value);
                           });

     }



  function generate(type) {
    var n = noty({
        text: 'The item(s) have been added to your basket.',
        type: type,
      dismissQueue: true,
        layout: 'topCenter',
        theme: 'defaultTheme'
    });
    console.log('html: '+n.options.id);

         setTimeout(function() {
      $.noty.closeAll();
    }, 5000);
  }




});
3
  • Which version of jQuery, and which version of IE are you using? Commented Jan 30, 2013 at 22:15
  • 1
    Is there any error in the IE javascript console? Commented Jan 30, 2013 at 22:15
  • You are missing a semi colon on this line "var L = $(this).attr('name')", but that's probably not it. Does the jQuery ready callback fire to even attach the event and is the element $('.addtobag') found? Commented Jan 30, 2013 at 22:20

4 Answers 4

1

Get rid of the console.log() statement. IE < 9 chokes on it and 9 only works if the console is open.

Sign up to request clarification or add additional context in comments.

Comments

0

Try adding an event parameter in your click callback

$('.addtobag').on('click', function(event){

Comments

0

A couple things that might be tolerated in some browsers and not IE are that line 12 is missing a semicolon at the end, and the variable phpbasket is not defined (although if you defined it outside of the closure with 'var phpbasket' then you should be ok. If you debug it in IE 9 or higher, you should be able to see line numbers of errors in the console.

Comments

0

Not a complete answer, but it may point you in the right direction. I was actually about to ask a similar question - I found how to get IE 11 to load the jquery, but it required the user to hit "f12" and then "run activex" because apparently IE considered my code potentially unsafe. But when the user tells the activex to run, it works fine.

I am trying to learn how to use jquery to make touchscreen-friendly dropdown menus, so my code was basic - no css, no doctype, just basic html and js. If anyone else could shed some light on this it would be great.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.