gpt4 book ai didi

javascript - 在Jquery中显示带有类的表

转载 作者:行者123 更新时间:2023-12-03 08:07:42 25 4
gpt4 key购买 nike

我想在我的 HTML 表中附加 jQuery 的一些值

$(document).ready(function() {
console.log("ready!");

// on form submission ...
$('form').on('submit', function() {

console.log("the form has beeen submitted");

// grab values
valueOne = $('input[name="perfid"]').val();

console.log(valueOne)

$.ajax({
type: "POST",
url: "/",
datatype:'json',
data : { 'first': valueOne},
success: function(result) {
console.log(result.result[0].userid);


$('#result').html("<table class="table table-bordered responsive"><tr><td>" + result.result[0].hosts[0].filer + "</td><td>" + result.result[0].hosts[0].hostname + "</td><td>" + result.result[0].hosts[0].model + "</td></tr></table>");


},
error: function(error) {
console.log(error)
}
});

});

});

我收到错误如下:语法错误:在该行的参数列表之后缺少 ) :

$('#result').html("<table class="table table-bordered responsive"><tr><td>" + result.result[0].hosts[0].filer + "</td><td>" + result.result[0].hosts[0].hostname + "</td><td>" + result.result[0].hosts[0].model + "</td></tr></table>");

有人可以指出出了什么问题吗?TIA

最佳答案

一切都与引号有关

$('#result').html('<table class="table table-bordered responsive"><tr><td>' + result.result[0].hosts[0].filer + '</td><td>' + result.result[0].hosts[0].hostname + '</td><td>' + result.result[0].hosts[0].model + '</td></tr></table>');

看看How to concatenate variable in string in javascript

关于javascript - 在Jquery中显示带有类的表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34305106/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com