Jump to content

cannot post form twice as it save data from last submit


farkewie

Recommended Posts

Hi i am new to ajax all i want this form to do it post 1 text field to my php  file,

 

I  am using the yahoo yui and its all working except when i try to usinsg it a second time it still sends the same as the last time i submitted it so...

 

first time i submit the word "test" and it displays "test in the container.

second time i use it i submit the word 1234" and it keeps displaying test i need it to clear all the previous data when i change the textfiels so then i dont need to refresh the page, can anyone help?

 


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Connection Manager POST Transaction</title>

<style type="text/css">
/*margin and padding on body element
  can introduce errors in determining
  element position and are not recommended;
  we turn them off as a foundation for YUI
  CSS treatments. */
body {
margin:0;
padding:0;
}
</style>

<link rel="stylesheet" type="text/css" href="../../build/fonts/fonts-min.css" />
<script type="text/javascript" src="yahoo.js"></script>
<script type="text/javascript" src="event.js"></script>
<script type="text/javascript" src="connection.js"></script>


<!--begin custom header content for this example-->
<style>
#container li {margin-left:2em;}
</style>


<!--end custom header content for this example-->

</head>




<body class=" yui-skin-sam">
<form name="tacform" id="tacform" method="post">
<input type="test" id="tac"/>


<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== -->

<div id="container"></div>

<script>
var div = document.getElementById('container');
var tac = document.getElementById('tac');

var handleSuccess = function(o){
YAHOO.log("The success handler was called.  tId: " + o.tId + ".", "info", "example");
if(o.responseText !== undefined){

	div.innerHTML += "<li>PHP response: " + o.responseText + "</li>";

}
};

var handleFailure = function(o){
	YAHOO.log("The failure handler was called.  tId: " + o.tId + ".", "info", "example");

if(o.responseText !== undefined){
	div.innerHTML = "<li>Transaction id: " + o.tId + "</li>";
	div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
	div.innerHTML += "<li>Status code message: " + o.statusText + "</li>";
}
};

var callback =
{
  success:handleSuccess,
  failure:handleFailure,
  argument:['foo','bar']
};

var sUrl = "post.php";
var postData = "tac=" + tac.value;

function makeRequest(){

var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);

YAHOO.log("Initiating request; tId: " + request.tId + ".", "info", "example");

}

YAHOO.log("As you interact with this example, relevant steps in the process will be logged here.", "info", "example");
</script>
<input type="button" value="Send a POST Request" onClick="makeRequest();"></form>

<!--END SOURCE CODE FOR EXAMPLE =============================== -->

</body>
</html>


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.