0

I just want to append the responseText from my php file to a div. The Content in the div should not be replaced but the responseText should be append to the existing div Content. The responseText is a Tag.

$(document).ready(function() {
var options = { 
  beforeSend: function() {
    $("#progress").show();
    //clear everything
    $("#bar").width('0%');
    $("#message").html("");
    $("#percent").html("0%");
  },
  uploadProgress: function(event, position, total, percentComplete) {
    $("#bar").width(percentComplete+'%');
    $("#percent").html(percentComplete+'%');
  },
  success: function() {
    $("#bar").width('100%');
    $("#percent").html('100%'); 
  },
  complete: function(response) {
    $("#message").append("<font color='green'>"+response.responseText+"</font>");   
//DOESN'T WORK      
      },
      error: function() {
        $("#message").html("<font color='red'> ERROR: unable to upload files</font>");
  } 
}; 

$("#uploadForm").ajaxForm(options); 
});
1
  • It means that it replace the content in the message div instead to append the responseText. Commented Jul 29, 2013 at 15:22

1 Answer 1

1

This line in beforeSend:

$("#message").html("");

plus line this in complete:

$("#message").append("<font color='green'>"+response.responseText+"</font>");

act as a content replacement instead of an append. Just remove the line in beforeSend.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.