Forum Moderators: open

Message Too Old, No Replies

working example of yahoo connection manager

         

nicknick

4:31 pm on Sep 14, 2008 (gmt 0)

10+ Year Member



Hi ,

I am looking for an example thats working using post and the yahoo connection manager ?

Ive tried using their help system and still cant get it working .

Any takers ?

Regards

Fotiman

4:21 pm on Sep 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Here's an example:
<?php 
if (array_key_exists('ajax', $_POST)) {
echo date('l jS \of F Y h:i:s A');
exit;
}
?>
<!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>Untitled</title>
</head>
<body>
<form action="index.php" method="post">
Name: <input type="text" name="username" id="username">
Time: <input type="text" name="time" id="time">
</form>
<!-- Scripts -->
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/connection/connection-min.js"></script>
<script type="text/javascript">
YAHOO.util.Event.onDOMReady(function () {
var elTime = document.getElementById('time');
var callback = {
success: function(o) {
elTime.value = o.responseText;
},
failure: function(o) {
alert('Error with AJAX request');
}
}
YAHOO.util.Event.on('username', 'keyup', function() {
var transaction = YAHOO.util.Connect.asyncRequest('POST', 'index.php', callback, "ajax=true");
});
});
</script>
</body>
</html>

nicknick

1:29 pm on Sep 18, 2008 (gmt 0)

10+ Year Member



Hiya i got some questions about this :

Im trying to get what i type in the left block to appear in the right block ?

so if i type malcolm then malcolm appers on the right block.

The reason i am doing thios is to confirm what is being posted is being actually posted.

<?php
if (array_key_exists('ajax', $_POST)) {
echo $_POST;
exit;
}
?>

So what im getting at the moment is the word array and was wondering what the method is to get around this ?

Fotiman

1:53 pm on Sep 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Change your echo statement to return exactly what you're trying to return. For example:

echo $_POST['username'];

And modify the Connection Manager script to include the form data (give the form an id as well):


<?php
if (array_key_exists('ajax', $_POST)) {
echo $_POST['username'];
exit;
}
?>
<!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>Untitled</title>
</head>
<body>
<form action="index.php" method="post" id="myform">
Name: <input type="text" name="username" id="username">
Time: <input type="text" name="time" id="time">
</form>
<!-- Scripts -->
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/connection/connection-min.js"></script>
<script type="text/javascript">
YAHOO.util.Event.onDOMReady(function () {
var elTime = document.getElementById('time');
var callback = {
success: function(o) {
elTime.value = o.responseText;
},
failure: function(o) {
alert('Error with AJAX request');
}
}
var formObject = document.getElementById('myform');
YAHOO.util.Connect.setForm(formObject);
YAHOO.util.Event.on('username', 'keyup', function() {
var transaction = YAHOO.util.Connect.asyncRequest('POST', 'index.php', callback, "ajax=true");
});
});
</script>
</body>
</html>