Pick up service html and display DIV on my website

Asked

Viewed 77 times

1

I have an Ajax function that returns me the html of a service that I have exposed, I would like to take this html and put inside the DIV of a site of my.

My function is already picking up html, but it displays html inside the DIV would like it to display content already format, without html tags

  • 2

    by jQuery: $("#suaDiv").html("<html> seu html </html>")

  • Perfect! It worked, buddy! Now I need to take the fields of my form and pass the url to the service, I tried like this: $.get('.endereco.com.br/Simulacao2',$('form_t'). serialize(),Function(responseText) { But it doesn’t take my form. You know pq?

  • See that it fits you:$("#suaDiv").html = $.parseHTML("<html> seu html </html>") or $("#suaDiv").html($.parseHTML("<html> seu html </html>"))

  • @William edits your question with the code you try to do the .get

  • I tried this: "$. get('endereco.com.br/Simulacao2',$('form_t'). serialize(),Function(responseText) { " The name of my form is fom_t

  • you’re sending it like it’s post, try like this: $.get('endereco.com.br/Simulacao2' + $('form_t').serialize(),function(responseTex‌​t) { }

  • @ Marllon Nasser It didn’t work, my form looks like this: <form id="form_t" name="form_t" class="col S12" method="post"> It doesn’t pass the fields to the url, funny that in the old version of my form worked.

Show 2 more comments

1 answer

3


Turning the comment into a response...

Just use jQuery:

$("#suaDiv").html("<html> seu html </html>")

To submit your form via get:

$.ajax({
    type: "GET",
    data:  $("#form_t").serialize(),
    url: "endereco.com.br/Simulacao2"
}).done(function(data){
    //tratamento
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.