Search code examples
javascriptjqueryajaxjquery-forms-plugin

How to append the ajax result to the target div id?


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

Solution

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