I am coming to an issue where I am appending to my table using jQuery and also to <div class="jobEntity" id="bestTable">
. For some reason I don't want to append my table like that. Is there a way to work around with my jQuery code to append the table properly? Thanks for the help.
var cache = {};
$("#searchTextField").autocomplete({
minLength: 2,
focus: function(event, ui) {
event.preventDefault();
},
source: function(request, response) {
var term = request.term;
if (request.term in cache) {
response(cache[request.term]);
return;
}
$.ajax({
url: "#{request.contextPath}/JobSearchItem.xhtml",
type: "GET",
data: {
term: request.term
},
dataType: "json",
success: function(data) {
response(data);
}
});
},
select: function select(event, ui) {
event.preventDefault();
var url = '#{request.contextPath}/index.xhtml';
var searchValue = ui.item.value;
var data = new FormData();
data.append('searchValue', searchValue);
$.ajax({
url: url,
data: data,
method: "POST",
processData: false,
contentType: false,
cache: false
}).done(function(text) {
$('#results').append($(text).find('#bestTable'));
$('#results').append($(text).find('#textTable'));
$('#results').append($(text).find('table'));
$("#clearone").show();
});
},
response: function response(event, ui, data) {
if (!ui.content.length) {
var message = {
value: "",
label: "NOTHING HAS BEEN FOUND"
};
ui.content.push(message);
}
}
});
Well you could do something like this:
$.ajax({
url: url,
data: data,
method: "POST",
processData: false,
contentType: false,
cache: false
}).done(function(text) {
let append = $(text).find('#bestTable').text() + $(text).find('#textTable').text() + $(text).find('table').text();
$('#results').append(append);
$("#clearone").show();
});
As an idea, first prepare the append content and then append at once.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.