【发布时间】:2012-02-17 02:52:55
【问题描述】:
我在 WordPress 中使用Thickbox,上传Thickbox 后将数据发送回编辑器(上传字段),整个jQuery 代码看起来就像here:
jQuery(document).ready(function() {
jQuery('#upload_image_button').click(function() { //user clicks upload button
tb_show('', 'media-upload.php?type=image&TB_iframe=true'); //Thickbox pop-ups
return false;
});
window.send_to_editor = function(html) { //here's our callback function
imgurl = jQuery('img',html).attr('src');
jQuery('#upload_image').val(imgurl); //that's how we send something to front-end
//how to send "imgurl" to back-end within this function?
tb_remove(); //closes Thickbox
}
});
我想知道将变量从 JS 发送到 PHP 的最佳方式是什么(我想将其发送到 WP 函数,以便使用 update_option('option_name','variableFromJS'); 将其注册为“选项”。
请记住,Thickbox 是在 iframe 中打开的,所以我只有这个回调函数。
【问题讨论】:
标签: php javascript jquery post thickbox