1

I have another weird little jquery-ajax problem. The script below works perfectly upon multiple clicks in FF and chrome, but only works the first click in ie. I have viewed it in firebug and no problems. I have similar jq scripts that can repeat infinately just fine, but can't figure out why this one won't.

Now that I think of it the other scripts are POST requests, FYI. ANY IDEAS?

JQuery-AJAX script below:

$('.activity').on('click', '.tip', function(e){
    e.preventDefault();
    var tip = $(this);
    var class_tips = tip.parent();
    var actID = class_tips.find('.value').val();
    $.ajax({
        type: "GET",
        data: "captip=" + actID,
        url: "includes/tips.php",
        success: function(msg){
            class_tips.find('.tips_right').html(msg);
        }
    });
    return false;
})
Bill Chambers
  • 83
  • 1
  • 9
  • You want this to be work for all new DOM elements you got from the server response, right? – Yang Feb 14 '13 at 06:56
  • metal_fan, it works the first go round in ie but not if the click function is run a second time, but sequentially in ff and chrome as expected. – Bill Chambers Feb 14 '13 at 06:59

1 Answers1

0

I think if you return true on success it should reset the e.preventDefault();

$('.activity').on('click', '.tip', function(e){
    e.preventDefault();
    var tip = $(this);
    var class_tips = tip.parent();
    var actID = class_tips.find('.value').val();
    $.ajax({
        type: "GET",
        data: "captip=" + actID,
        url: "includes/tips.php",
        success: function(msg){
            class_tips.find('.tips_right').html(msg);
            return true;
        }
    });
    return false;
})
Dalorzo
  • 19,834
  • 7
  • 55
  • 102
danc403
  • 84
  • 1
  • 7