weixin_33720078 2019-02-10 19:46 采纳率: 0%
浏览 84

在div中添加响应ajax

I am trying to add a response in json format to a column but I get the following error: "Uncaught TypeError: response[i].name.appendTo is not a function".

function allUsers(){
        $(".error").remove();
        $("#tabla").remove();
        $.ajax({
            type: "GET",
            url: "mylocalhost/public/api/user",
            contentType: "application/json",    
            dataType:'json',

             beforeSend: function(request) {
                    request.setRequestHeader("Authorization", localStorage.getItem("token"));
                },
            success: function(response){
                console.log(response);




for (i = 0; i < response.length; i++) {

                    $('<div class="prueba"/><br>')+(response[i].name).appendTo('#filaNombre');

                    ...
  • 写回答

2条回答 默认 最新

  • weixin_33739523 2019-02-10 19:52
    关注

    Try changing this line:

    $('<div class="prueba"/><br>')+(response[i].name).appendTo('#filaNombre');
    

    to this:

    $('<div class="prueba"><br>' + response[i].name + '</div>').appendTo('#filaNombre');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序