我正在使用ajaxForm.js进行ajax图像上传。
这是我使用的js函数:
$(document).ready(function() {
$('#photoimg').live('change', function() {
$("#hd_pic").html('');
$("#loading").html('<img src="../img/common/loader.gif"/>').fadeIn(250);
$("#imageform").ajaxForm({
target: '#hd_pic'
}).submit();
});
});
我不想将结果输出到target:'#hd_pic',但我想调用一个函数。例如,我在ajax调用中是这样做的:
$.ajax({
type: "POST",
url: "/ajax/add_url.php",
data: dataString,
}).done(function(result) {
myresult(result);
});
我调用函数myresult并使用ajax调用的结果。我也想在ajaxform提交函数中做这件事。有可能做到这一点吗?
这不起作用:
$("#imageform").ajaxForm({
success: myresult(result)
}).submit();
发布于 2012-08-20 19:59:43
我认为你可以这样做:
$("#imageform").ajaxForm({
success: myresult
}).submit();
发布于 2012-08-20 19:59:08
可以使用成功回调属性作为options之一,而不是使用目标
$("#imageForm").ajaxForm({
success: function() {
// your callback code goes here
}
});
发布于 2012-08-20 19:59:53
您想要的确切语法
$("#imageform").ajaxForm({
target: '#hd_pic',
success: function(){/*your code after here*/}
})
https://stackoverflow.com/questions/12044222
复制相似问题