Hello All my friend ..... I have the following code it work well .... but in some case the image which round(ajax image ) continue rounding , I mean that the code in reponse section doesnt work , becuse I put in response section code to hide image which tell him waiting .

the code

$('#B3').click(function(){

    if ($('#t1').val()!="" && $('#t2').val()!="" && $('#t3').val()!="" && $('#t4').val()!="" && $('#t5').val()!="" && $('#t6').val()!="" && $('#t7').val()!="" && $('#t8').val()!="" && $('#t9').val()!="" && $('#t10').val()!="" && $('#t11').val()!="" && $('#t12').val()!="" && $('#t13').val()!="" ){
    $('#error').hide();
    $('#startex').show();

    $.getJSON("insertmaster.php?ran="+Math.random(),{t1:$('#t1').val(),t2:$('#t2').val(),t3:$('#t3').val(),t4:$('#t4').val(),t5:$('#t5').val(),t6:$('#t6').val(),t7:$('#t7').val(),t8:$('#t8').val(),t9:$('#t9').val(),t10:$('#t10').val(),t11:$('#t11').val(),t12:$('#t12').val(),t13:$('#t13').val()},function(data){

    $('#startex').hide();
    if (data=="done"){
    $('#doneex').show();
    } else {
    $('#alreadyexsits').show();
    }

    });

    }else {
    $('#startex').hide();
    $('#error').show();
    }







    ///////////////////////////////
    });



what is the problem ????

Recommended Answers

All 4 Replies

Try this out:

$('#B3').click(function(){

    var hasError = false,
        jsonData = {},
        $startex = $("#startex"),
        $error = $("#error");

    // Verify value for all fields and create the json data
    for( var i=1; i < 14; i++) {
        var val = $('#t' + i).val();
        if ( val == '' ) {
            hasError = true;
            break;
        }
        jsonData['t' + i] = val;
    }

    // If has errors show the message and stop the process
    if ( hasError ) {
        $startex.hide();
        $error.show();
        return;
    }

    $error.hide();
    $startex.show();

    $.getJSON("insertmaster.php?ran="+Math.random(), jsonData, function(data){

        $startex.hide();

        if (data=="done"){
            $('#doneex').show();
        } 
        else {
            $('#alreadyexsits').show();
        }
    });

});

Thanks dear ...... but what is the difference between my code and your ?????? is your code solve the problem >>>> and how

I mean .... where is the bug in my code

ita, I'm really not sure.

When I see a ugly code with bugs, I think it's easiest to remake the code. Cause normally it's solves the problem, and even if it doesn't, it'll be much simplier to debug it.

But I really don't know the bug in your code, I didn't find any by looking at it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.