In this example, I want "ABC" to be replaced with "XYZ":
http://pastehtml.com/view/1avqmak.html
I am posting data using AJAX and I want to use JavaScript to replace the response before the response is returned. If you test the link above you will see the issue.
Here is my code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Example</title>
<script type="text/javascript" src="http://www.twilightuniverse.com/downloads/sack/tw-sack.js"></script>
</head>
<body>
<div id="r"></div>
<input type="button" value="Click Here to Test" onclick="runAjax()" />
<script type="text/javascript">
/*<![CDATA[*/
function runAjax() {
var aj = new sack();
aj.setVar('item', 'value');
aj.requestFile = 'submit.html';
aj.method = 'POST';
aj.element = 'r';
aj.runAJAX();
alert('I want ABC to be replaced with XYZ.');
}
/*]]>*/
</script>
</body>
</html>