How to put the Ajax return [form] inside a div?

1
$.ajax({
    url: 'executa.php',
    type: 'POST',
    data: {emailDestino: emailDestino},
    dataType: 'html',
    success: function(data) {
        $('#notifyInscrito').appendTo(data);
    }   
});

I'm going there in the executa.php file via ajax with an email, and doing a query to mount an HTML with the returned data, and I want to put that complete HTML inside div #notifyInscrito . That is a lightbox that will immediately send an email to the record of the returned data.

I tried to make a $('#notifyInscrito').appendTo(data) in the intention of returning the form from within executa.php and inserting within div but did not work.

Question: How do I get the HTML of executa.php and put within div #notifyInscrito ?

    
asked by anonymous 26.11.2015 / 01:59

1 answer

4

The "date" that is returned to you is an object, it should be read as data.algumacoisa or data['algumacoisa'] .

Try to use a function in execute.php that returns a TEXT to you because you have defined HTML as dataType , that is: Text.

You can make this code:

$.ajax({
    url: 'executa.php',
    type: 'POST',
    data: {emailDestino: emailDestino},
    dataType: 'html',
    success: function(data) {
        $('#notifyInscrito').html(data.algumacoisa);
    }   
});
    
26.11.2015 / 06:45