soumya
soumya

Reputation: 35

jQuery doesn't work in IE but it works in Mozilla

Please help me my jQuery script doesn't work ie8 but works in FF please verify my code is there any error?

<div class="check_out_button" id="checkout" style="cursor:pointer"><?=translate('Check Out',$lang)?></div>

$(document).ready(function(){
    $('#checkout').click(function(){

    var amount = $('#dnt_amount').val();
    var flag = 0;

    if(amount == "")
    {
        $('#amounterr').css("display","block");;
        flag++;
    }

    if(flag == 0)
    {
        var res = $("#form1").serialize();

        $.ajax({  
                    type: "POST",  
                    url: "<?=site_url('profile/checkout')?>",  
                    data: res,

                    success: function(msg)
                        {
                            $('#amount').val(amount);
                $('#amt').val(amount);
                $('#amounterr').css("display","none");
                $("#fundraiser").css("display","none");
                $("#fundraiser1").css("display","block");
                $("#about").css("display","none");
                        }  
                    }); 
            }           
        });
    });

Upvotes: 0

Views: 1582

Answers (3)

Muhamad Bhaa Asfour
Muhamad Bhaa Asfour

Reputation: 1035

Try this, there were some javascript errors like an unnecessary additional semicolon in line 8.

$(document).ready(function() {
    $('#checkout').click(function() {

        var amount = $('#dnt_amount').val();
        var flag = 0;
        if (amount === "") {
            $('#amounterr').css("display", "block");
            flag++;
        }
        if (flag === 0) {
            var res = $("#form1").serialize();

            $.ajax({
                type: "POST",
                url: "<?=site_url('profile/checkout')?>",
                data: res,

                success: function(msg) {
                    $('#amount').val(amount);
                    $('#amt').val(amount);
                    $('#amounterr').css("display", "none");
                    $("#fundraiser").css("display", "none");
                    $("#fundraiser1").css("display", "block");
                    $("#about").css("display", "none");
                }
            });
        }
    });
});

Upvotes: 4

Mikael Eliasson
Mikael Eliasson

Reputation: 5227

I would start by cleaning up that code a bit like the double ;; and in javascript you should always place the { at the end of the line.

//Bad
if()
{
}

//Good
if(){
}

You can read more about why here I'm not sure if that is the problem here but worth a try. If not we need more details.

Upvotes: 1

rsp
rsp

Reputation: 111336

Do you have a doctype? Do you tell the browser to use the most recent rendering engine? Which version of IE are you using? You only say that it doesn't work in IE but you don't say what do you mean by that. It's a wild guess that if it works in other browsers and not in IE then maybe your page gets rendered in quirks mode and you have some issues with event models. See this answer that I posted recently.

Upvotes: 0

Related Questions