Php 如何在另一页中追加和回显图像
我正在使用一个表单插件(确切地说是jqueryformplugin),我想知道如何附加处理页面中回显的数据。我要附加的文件是一个图像文件 jQuery:Php 如何在另一页中追加和回显图像,php,jquery,Php,Jquery,我正在使用一个表单插件(确切地说是jqueryformplugin),我想知道如何附加处理页面中回显的数据。我要附加的文件是一个图像文件 jQuery: $(document).ready(function () { var options = { target:'.prof_img', // target element(s) to be updated with server response url:'upload_profile_pic.p
$(document).ready(function () {
var options = {
target:'.prof_img', // target element(s) to be updated with server response
url:'upload_profile_pic.php',
type:'POST',
success:function() {
$("#theater_outer").hide();
$('a[class="prof_img"]').empty(); //where prof_img is the div i want to empty and append the image inside
$('a[class="prof_img"]').append(data);
}
};
$('#upload_profile_photo').ajaxForm(options);
})
您需要
success
回调函数中的数据参数
$(document).ready(function () {
var options = {
target:'.prof_img', // target element(s) to be updated with server response
url:'upload_profile_pic.php',
type:'POST',
success:function(data) {
$("#theater_outer").hide();
$('a[class="prof_img"]').empty(); //where prof_img is the div i want to empty and append the image inside
$('a.prof_img').append($(data));
}
};
$('#upload_profile_photo').ajaxForm(options);
});
请尝试以下操作:
$(document).ready(function () {
var options = {
target:'.prof_img', // target element(s) to be updated with server response
url:'upload_profile_pic.php',
type:'POST',
success:function(img) { //img should be the server side response
$("#theater_outer").hide();
$('a.prof_img').html(img); //replace inner html with the image html
//^ simpler class based selector
}
};
$('#upload_profile_photo').ajaxForm(options);
});
我不是舒尔我跟着你当你现在运行脚本时,当
数据
附加到您的链接时,它是什么样子的?没有附加任何内容。基本上我想做的是清除prof_image中的图像,并将其附加到procesor文件中回显的图像中。我们需要知道的是上载配置文件\u pic.php
打印的数据。如果它只是echo$someImage
其中$someImage
是一个二进制文件,那么您需要echo base64\u encode($someImage)
采用我建议的方法。您忘记了成功:函数(数据){/code>