gpt4 book ai didi

jquery - 需要有关此脚本的帮助

转载 作者:行者123 更新时间:2023-12-01 03:55:18 25 4
gpt4 key购买 nike

我正在使用以下脚本在我的动态页面上获取 Gravatar,

<input type="text" id="email" value="{$clientemail}" style="display:none;"/> 

$(document).ready(function(){
$('.p').append($.gravatar($('#email').val(), {
method: 'append',
size: '100',
image: '/images/1.png',
rating: 'r'
}));
});


<div class="p" style="width:100px;height:100px">

我必须使用另一个页面中的以下代码加载 {$clientemail} 的值。

$('#email').load('clientarea.php? #clientemail');

我的问题是 .load 需要几秒钟的时间来加载,因此 .append 正在发送空值,导致默认的 Gravatar 图片。

我该如何克服这个问题?

谢谢

最佳答案

您需要将附加代码粘贴到 load 回调中,如下所示:

$('#email').load('clientarea.php? #clientemail' function() {
$('.p').append($.gravatar($(this).val(), {
method: 'append',
size: '100',
image: '/images/1.png',
rating: 'r'
}));
});

不过,.load()不建议将其放入这样的输入元素中,最好使用 $.get()请求并获取该值,如下所示:

$.get('clientarea.php?', function(data) {
var val = $('#clientemail', data).val();
//if needed: $('#email').val(val);
$('.p').append($.gravatar(val, {
method: 'append',
size: '100',
image: '/images/1.png',
rating: 'r'
}));
});

关于jquery - 需要有关此脚本的帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3377816/

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