weixin_33725272 2015-02-13 16:07 采纳率: 0%
浏览 11

Ajax + js(无jquery)

I have a trouble with IE. This code isn't working in IE, but in others it works well. I found that IE isn't working with jQuery AJAX, so its need to be without. Maybe somebody knows about this

$(document).ready(function () {
    $.ajax({
        url: 'http://api.randomuser.me/?results=11',
        dataType: 'text',
        success: function (result, textStatus, XMLHttpRequest) {
            console.log(result);
            //alert(result);
            var event = JSON.parse(result);
            var our_html = "<table 'border='0' cellpadding='0' cellspacing='0'>";
            our_html += "<tr><th style='width:52px;border-left:none;'>№</th><th>Имя Фамилия Отчество</th><th>Адрес</th><th>Фото</th><th style='width:180px;border-right: none;'>Действие</th></tr>";
            event.results.forEach(function (item, item_number) {
                var u = item.user;
                our_html += "<tr>";
                our_html += "<td style='width:52px;'>" + (parseInt(item_number) + 1) + "</td>";
                our_html += "<td class='usname'>" + u.name.title + "." + "<span>" + u.name.first + "</span>" + " " + "<span>" + u.name.last + "</span>" + "</td>";
                our_html += "<td class='usst'>" + "<span>" + u.location.city + "</span>" + ", " + u.location.street + "</td>";

                our_html += '<td style="width:146px;"><img style="max-width:60px; max-height:60px;border-radius: 30px;" src="' + u.picture.medium + '"></td>';
                our_html += '<td style="width:180px; border-right: solid 1px #e1e1e1;"><div class="more" onclick="alert("' + u.name.first + '")">Просмотреть</div></td>';
                our_html += "</tr>";
            });
            our_html += "</table>";

            document.getElementById("table-wrapper").innerHTML = our_html;
            //alert (event.results[0].user.name.title);  // Goper
            //$(".simple p").text(event.results[0].user.name.title);
        }
    });
});
  • 写回答

2条回答 默认 最新

  • weixin_33743661 2015-02-13 16:16
    关注

    Since you are already using jQuery, you should use that instead of vanilla DOM scripting.

    Instead of

    document.getElementById("table-wrapper").innerHTML=our_html;
    

    try using:

    $('#table-wrapper').html(our_html);
    

    Works here: http://jsbin.com/zoyinoguri/1/edit?html,js,output

    评论

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能