Mettre à jour div avec jQuery ajax response html

Mots clés : jqueryajaxasp-classicgetreplacewithjquery

meilleur 3 Réponses Mettre à jour div avec jQuery ajax response html

vote vote

93

$('#submitform').click(function () {     $.ajax({         url: "getinfo.asp",         data: {             txtsearch: $('#appendedInputButton').val()         },         type: "GET",         dataType: "html",         success: function (data) {             var result = $('<div />').append(data).find('#showresults').html();             $('#showresults').html(result);         },         error: function (xhr, status) {             alert("Sorry, there was a problem!");         },         complete: function (xhr, status) {             //$('#showresults').slideDown('slow')         }     }); }); 
vote vote

89

$('#submitform').click(function() {      $.ajax({      url: "getinfo.asp",      data: {          txtsearch: $('#appendedInputButton').val()      },      type: "GET",      dataType : "html",      success: function (data){          $('#showresults').html($('#showresults',data).html());          // similar to $(data).find('#showresults')      }, }); 
// codes  success: function (data){    $('#showresults').replaceWith($('#showresults',data)); }, 
vote vote

76

$('#submitform').click(function() {   $('#showresults').load('getinfo.asp #showresults', {     txtsearch: $('#appendedInputButton').val()   }, function() {     // alert('Load was performed.')     // $('#showresults').slideDown('slow')   }); }); 
$( "#result" ).load( "ajax/test.html #container" ); 

Questions similaires