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();
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