2017-04-24 5 views
0

Ich habe div, wo ich einige Daten auf Knopf klicken anschließe. Hier ist der CodeKlare div auf Knopf klicken (ASP.NET)

$('#display').click(function() { 
    $(".videolist").empty(); 
    var vacancyId = $("#vacancy").val(); 
    var model = { 
     vacancyId: vacancyId 
    }; 
    var today = new Date(); 
    var yyyy = today.getFullYear(); 
    $.ajax({ 
     url: '@Url.Action("Links", "Questions")', 
     contentType: 'application/json; charset=utf-8', 
     data: JSON.stringify(model), 
     type: 'POST', 
     dataType: 'json', 
     processData: false, 
     success: function (data) { 
      var question2 = data; 

      for (var i = 0; i <= question2.length - 1; i++) { 
       var videoHTML = '<div style="width:100%;overflow-y: scroll;background:white;height:60%;border-bottom:solid;border-color: #A9A9A9;">' + '<div style="float:left; width:50%;height:296px;border-right:solid;border-color: #A9A9A9;margin-bottom:10px;">' + 
        '<video style="width:100%;height:290px; object-fit: contain;padding-right: 15px;padding-left:15px;" controls>'; 
       videoHTML += '<source src="' + document.location.origin + "/uploads/" + question2[i].Linkes + ".webm" + '" type="video/webm">'; 
       videoHTML += '</video>' + '</div>' + '<div style="float:right;width:48%;text-align:center;height:296px;padding-top:30px;">' + '<div style="font-size:20px">' + '<b>' + question2[i].FIO + '</b>' + '</div>' + '<div style="font-size:20px">' + '<b>' + question2[i].City + '</b>' + '</div>' + '<div style="font-size:20px">' + '<b>' + (yyyy - question2[i].Vozrast) + '</b>' + '</div>' + '<div class="qustion-div-two" style="height:160px;margin-top:20px; background:white;" >' + 
        '<div id="comments" style="width: 100%; height: 70%;">' + '</div>' + 
        '<div id="write_field" style="width:100%;height:30%;">' + 
        '<input type="text" style="width:99%; height:75%;margin-left:2px;margin-bottom:5px;" />' + '</div>' + '</div>' + '</div>'; 
       $(".videolist").append(videoHTML); 

      } 
     } 
    }); 
}); 

Wenn ich wählen Sie eine andere freie Stelle ich vorherigen erzeugt divs zu sehen.

Ich versuche, es über diese $(".videolist").empty(); zu löschen, aber es funktioniert nicht. Wo ist mein Fehler?

Danke für Hilfe.

+0

'empty()' sollte gut funktionieren. Haben Sie Fehler in der Konsole? –

+2

verwenden Sie IE? wenn ja, kann es Ajax-Anfragen zwischenspeichern. füge cache hinzu: false als Parameter für deinen Ajax-Aufruf und sieh nach, ob das den Fehler behebt –

+0

Alle Arbeiten scheinen so zu sein, als wäre es Cache. Danke Dude @ Andrewrebrough –

Antwort

0

Mit diesem Code:

$(".videolist").html('');

es funktionieren sollte