我正在使用表单插件(确切地说是jQuery表单插件),我想知道如何将处理页面中回显的数据附加到我想要追加的文件是图像文件。
jQuery的:
$(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);
})
答案 0 :(得分:0)
您需要success
回调function
$(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);
});
答案 1 :(得分:0)
尝试以下方法:
$(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);
});