i have a jquery function that gets a code WOEID from request string and returns the current weather for this town with YQL. The Jquery gets the code fine I also use the $.ajax POST to self page submit, in order to print the code in plain text to client.
The problem is that in client page there is nothing displayed BUT in Firebug i can see the value into console.... please help me i spend so many hours! My experience in php is beginner..
KAIROSMOU.js file
function getParameterByName(name) {
var match = RegExp('[?&]' + name + '=([^&]*)')
.exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}
// set the location's WOEID
var woeid = getParameterByName('woeid');//9848; // where on earth IDs: http://woeid.rosselliot.co.nz/
// use YQL to get restful JSON
var yql = 'http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%3D' + woeid + '&format=json&diagnostics=true&callback=?';
$.getJSON(yql, function(cbfunc) {
var condition = cbfunc.query.results.channel.item.condition.text;
var code = cbfunc.query.results.channel.item.condition.code;
// the above list is not comprehensive
condition = condition.toUpperCase();
// $('body').append( condition ) ;
// $('body').append( "$" );
// $('body').append( code );
$.ajax({
type: "POST",
url: "kairos.php",
dataType : 'HTML',
data: { WEATHER_CODE: code }
}).done(function( msg ) {
});
//dont work...either
// $.ajax({
// url: "kairos.php",
// dataType: 'json',
// type: 'GET',
// data: {
// WEATHER_CODE: code }
// });
});
KAIROS.PHP I CALL THIS PAGE LIKE THIS. mywebsite/kairos.php?woeid=9848
<html>
<head>
<script type='text/javascript' src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type='text/javascript' src="/KAIROSMOU.js"> </script>
</head>
<body >
<form >
<?php
$var_value = $_POST['WEATHER_CODE'];
printf("#"); // THIS WORKS APPEARS IN CLIENT
printf( $var_value ); //DONT WORK
?>
</form> </body>
</html>
THIS IS WHAT IS SEE IN FIREBUG CONSOLE You can see the #30 this is what i whant for client page to be shown but in vain...
<html>
<head>
<script type='text/javascript' src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type='text/javascript' src="/KAIROSMOU.js"> </script>
</head>
<body >
<form >
#30</form> </body>
</html>
AND THIS IS MY CLIENTS PAGE
<html>
<head>
<script type='text/javascript' src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type='text/javascript' src="/KAIROSMOU.js"> </script>
</head>
<body >
<form >
#</form> </body>
</html>