Panagiotis Koursaris Panagiotis Koursaris - 1 year ago 119
HTML Question

Remove specific inputs after $.ajax call

I have build some inputs to let the user search the database. The search is using ajax request.

The problem that I have is because when I get the response from the server I also get the search inputs. I don't want that.

Take a look to my code:.

$(document).on('change', '.auto-select', function(e){


var tags = $('#auto-tag-script').serialize();
var contracts = $('#auto-contract-script').serialize();
var educations = $('#auto-education-script').serialize();
var towns = $('#auto-town-script').serialize();

runAjax(tags, contracts, educations, towns);


function runAjax(tags, contracts, educations, towns) {
url: 'http://localhost/jobs/public/anazitisi-ergasias?' + tags + '&' + contracts + '&' + educations + '&' + towns





With the above code the inputs appears again in my page.

Is there any way to escape this form inputs.

Answer Source

You can hide it 2 ways...before you insert it (best way) or after you insert it

        url: '...'
        // create jQuery object from response
        var $html = $(data);
        //hide within that object
        // insert the object
         /*******   OR ***************/
        //  the html is in the DOM now, can do whatever might be needed to it


For many plugins you would need to insert first and then call the plugin

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download