[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Append AJAX Response Message

Posted on 2009-02-10
2
Medium Priority
?
380 Views
Last Modified: 2012-08-13
I use the following code to submit a form and get a response using AJAX.

http://d9qjx79zqpo3.googlepages.com/demo.html
http://d9qjx79zqpo3.googlepages.com/sackDemo.zip

When the form has been submitted, a response in placed in placeholder div: "Successfully Saved"

Now you only ever see on response: "Successfully Saved"

I want the response to be APPENDED to the contents of the placeholder div, not to replace the contents.

So if a user submits the form 10 times they should see 10 messages: "Successfully Saved" -- each one under the one before it.
0
Comment
Question by:hankknight
2 Comments
 
LVL 11

Expert Comment

by:flipz
ID: 23603886
In your line of code that sets the wording in the div - something like:

document.getElementById('divID').innerHTML = 'Successfully Saved';

change to:

document.getElementById('divID').innerHTML = document.getElementById('divID').innerHTML + '<br/>Successfully Saved';
0
 
LVL 43

Accepted Solution

by:
David S. earned 2000 total points
ID: 23604000
"Successfully Saved" comes in the AJAX response. While you could modify SACK, I don't recommend it.

Try this:
var numContainers = 1;
function doit(){
  var box = document.getElementById('container');
  var box2 = document.createElement('div');
  box2.id = 'container'+(++numContainers);
  box.parentNode.insertBefore(box2,box.nextSibling);
	var form = document.getElementById('form');
	ajax.setVar("myTextBox", form.mytext.value); // recomended method of setting data to be parsed.
	ajax.requestFile = "5process.html";
	ajax.method = form.method.value;
	ajax.element = 'container'+numContainers;
	ajax.onLoading = whenLoading;
	ajax.onLoaded = whenLoaded; 
	ajax.onInteractive = whenInteractive;
	ajax.onCompletion = whenCompleted;
	ajax.runAJAX();
	scroll(0,9999);
}

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question