I am using the following ajax code to get the result form another one php, now I need to append the result to the appropriate div(preview) id
$("#imageform").ajaxForm({
target: '#preview'
}).submit();
If you are using jQuery Form Plugin, Use like this..data is the data which you are sending from php file.
$("#imageform").ajaxForm({
clearForm: 'true',
success: function(data){
if(data != '')
{
$("#preview" ).append(data);
}
}
}).submit();
Use the success
callback function and don't specify the target
option.
$("#imageform").ajaxForm({
success: function(d,s,x){
$("#preview").append(d);
}
}).submit();
The problem is that the target
option is used to "replace" the target (or contents of the target) along with the replaceTarget
option. But since what you need to "append" instead of "replace", you should avoid the whole target
/ replaceTarget
mechanism
If you are using jQuery Form Plugin , according to it's documentation you can use
success
API: Callback function to be invoked after the form has been submitted. If a 'success' callback function is provided it is invoked after the response has been returned from the server.
$("#imageform").ajaxForm({
target: '#preview',
success: function() {
$('#preview').fadeIn('slow');
}
}).submit();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.