1

I have a form. After getting a specific string from a jQuery Ajax request, I want to clear some input fields of a form by jQuery id selector. What should I do ?

My jQuery code:

    $.post(site_url.concat('xml_request/cert.php') , { special_code:special_code , cert_id_name:cert_id_name , recive_date:sector_dob5 , about_cert:about_cert } , function(data){


    $('#add_cert_feedback').html(data);

    if (data.indexOf('New Certificate is now Added') !== -1) {

        //Want to reset a Input field here

    } else {

        $('#the_heck').html('shit!');           
    }

    $.post(site_url.concat('xml_request/cert.php') , { special_code:'_get_array_cert' } , function(data){

        $('#cert_load').html(data);

    });

});

1 Answer 1

2

You can use below code to clear input field -

$('#inputId').val('');

I have used id selector, you can use class or any other selector for selecting input (as per your requirement) and set empty string in .val('') to clear its value.

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

1 Comment

Thanks! :-D @Bhushan kawadkar

Your Answer

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