gpt4 book ai didi

javascript - ajax处理成功后如何显示图像

转载 作者:行者123 更新时间:2023-12-02 20:13:47 24 4
gpt4 key购买 nike

我想在向数据库提交数据后显示二维码这是我的提交代码:

 $(document).ready(function(){
$("input#submitmap").click(function() {
var routedmap =
{
destination :destinationDB,
point: addressRoute

};

$.ajax({
type: 'POST',
url: 'addroutedmap.php',
data: routedmap,
success: function(data){


}
});
});

});

在提交后的成功函数中,我想显示二维码的图像,这是图像的代码:

<img src="https://chart.googleapis.com/chart?
cht=qr&amp;chs=200x200&amp;chl=http://www.facebook.com"></img>

我尝试过使用 .show .html (+data+ ) 但它不起作用。有什么想法或建议吗?

最佳答案

你尝试过这个吗:

$('body').append('<img src="https://chart.googleapis.com/chart?cht=qr&chs=200x200&chl=http%3a%2f%2fwww.facebook.com" />');

或者:

$('#container').html('<img src="https://chart.googleapis.com/chart?cht=qr&chs=200x200&chl=http%3a%2f%2fwww.facebook.com" />');

其中 #container 是一些用于保存图像的 DOM 元素。

或者我喜欢的方式:

$('#container').html(
$('<img/>', {
src: 'https://chart.googleapis.com/chart?cht=qr&chs=200x200&chl=http%3a%2f%2fwww.facebook.com',
alt: ''
})
);

关于javascript - ajax处理成功后如何显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6615661/

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