dounong5373 2011-03-18 10:38
浏览 35
已采纳

jQuery并返回HTML

This is probably a no-brainer but I'm stuck.

I've a function which creates a table:

function getTable(someJSON, someGroup){
  var table = $("<table>").attr("class", "someTable");
  var row1 = $("<tr>");
  var cell1 = $("<td>").text(someJSON.someThing);
  row1.append(cell1);
  var cell2 = $("<td>").text(someJSON.someThingElse);
  row1.append(cell2);
  var row2 = $("<tr>");
  row2.append("<td>Something</td><td>Something else</td>");
  table.append(row2);
  var row3 = $("<tr>").append(getRow(someJSON, someGroup));
  table.append(row3);
  return table;
}

The table is returned okay but there's nothing in the last row.

getRow is like this:

function getRow(someJSON, someGroup){
  $.ajax({
    url: 'getRow.php',
    data: ({
      DM: JSON.stringify(someJSON),
      someGroup: someGroup
    }),
    async: false
  })
}

I've checked with FireBug and the getRow.php returns a valid result like: 123234 after doing it's thing but I'll be blown if I can get it into the ... I've been thrashing around with it and in an earlier iteration I had something like [object Object] appended to the row.

Any help would be greatly appreciated.

Cheers,

Dom

  • 写回答

3条回答 默认 最新

  • doubei5310 2011-03-18 10:42
    关注

    getRow does not return anything - that's why your last row is empty :)

    But even after you'll fix it - you append it to the TR without a TD inside, so it will not appear in the right place on the screen

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器