简体   繁体   中英

Ajax jquery not work on IE6

I'm working with ajax jquery. Follow code work fine with all browser except IE6. I tried to change something but it doesn't work.

Please help me to fix that! Thanks

$(document).ready(function(){
    $("#form_get").submit(function(){
        var hasError = false,
        inputURL = $("#input_link").val();
        $('#form_get input').attr('disabled', true);
        $("#result_file h3").html('Loading ...');
        $("#result_text").html('<div style="text-align:center;"><img src="./images/lightbox-ico-loading.gif" /></div>');
        $("#result_file").slideDown('slow');
        var request = $.ajax({
            url: "get.php",
            type: "POST",
            data: {input_link : inputURL},
            dataType: "html",
            cache: false,
            timeout: 10000,
        });
        request.done(function(msg) {
            var aResult = JSON.parse(msg);
            $('#result_file h3').html(aResult.status);
            $("#result_text").fadeTo('slow',0,function(){
                $('#result_text').html(aResult.text);
                $("#result_text").fadeTo('slow',1);
            });
        });
        request.fail(function(jqXHR, textStatus) {
            alert('Ajax Error');
            $('#result_file h3').html('Error');
            $("#result_text").html("Ajax doesn't work");
        });
        $('#form_get input').attr('disabled', false);
    return false;
    });
});

Try removing the extra comma in this part of the code:

var request = $.ajax({
    url: "get.php",
    type: "POST",
    data: {input_link : inputURL},
    dataType: "html",
    cache: false,
    timeout: 10000, //Remove this comma
});

So it should look like:

$(document).ready(function(){
    $("#form_get").submit(function(){
        var hasError = false,
        inputURL = $("#input_link").val();
        $('#form_get input').attr('disabled', true);
        $("#result_file h3").html('Loading ...');
        $("#result_text").html('<div style="text-align:center;"><img src="./images/lightbox-ico-loading.gif" /></div>');
        $("#result_file").slideDown('slow');
        var request = $.ajax({
            url: "get.php",
            type: "POST",
            data: {input_link : inputURL},
            dataType: "html",
            cache: false,
            timeout: 10000
        });
        request.done(function(msg) {
            var aResult = JSON.parse(msg);
            $('#result_file h3').html(aResult.status);
            $("#result_text").fadeTo('slow',0,function(){
                $('#result_text').html(aResult.text);
                $("#result_text").fadeTo('slow',1);
            });
        });
        request.fail(function(jqXHR, textStatus) {
            alert('Ajax Error');
            $('#result_file h3').html('Error');
            $("#result_text").html("Ajax doesn't work");
        });
        $('#form_get input').attr('disabled', false);
    return false;
    });
});

BTW a good html,css,javascript editor would pick up this syntax issue for you. I prefer to use Aptana 2.0.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM