gpt4 book ai didi

javascript - Ajax post 在 IE8 中不完全工作

转载 作者:行者123 更新时间:2023-12-03 10:30:56 25 4
gpt4 key购买 nike

我有一篇简单的文章,适用于除 IE 版本 8 之外的所有其他浏览器。

        $.post(             
"/pages/event_layout",
{ id: id },
function(html){
$('#the_content').html(html);
},
'html'
);

我意识到问题是这样的:enter image description here

当它发布和检索数据时,内容开头有一个空格,导致基本上什么也没有出现,或者是 IE8 的旧文本-空文本节点问题,因为微软太棒了。

所以在帖子中我尝试了这个来摆脱初始空间。

        $.post(             
"/pages/event_layout",
{ id: id },
function(html){
$('#the_content').html($.trim(html));
},
'html'
);

但无济于事。是否有 REGEX 或其他东西可以用来消除这个空间并且也兼容 IE8。

最佳答案

如果没有 AJAX 调用结果,很难提供正确的答案。下面的正则表达式将删除 HTML 开头的所有空白字符:

function(html){
$('#the_content').html(html.replace(/^\s+/, ""));
},

这是一个DEMO

关于javascript - Ajax post 在 IE8 中不完全工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29220101/

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