I passed variable from php to ajax call and it's not- solved
Posted: Mon Feb 10, 2014 12:28 pm
So I have this file where the ajax call starts
and this move.php
The problem is that the variable called 'tile' won't get passed to my ajax call.. which is really strange..
btw I already changed this
to this
to just try if it could work and it works perfectly.. So the problem over here is the variable passsing..
any help would be appreciated thanks
Code: Select all
<script type="text/javascript">
// if the user moves down
$(document).ready(function(){
$("#down").click(function(){
$.ajax({
type: "POST",
url: "move.php",
cache: false,
data: {move: "down"},
success: function(html){
$("#"+tile).html(html);
}
});
});
});
</script>
Code: Select all
<?php
include "config/connect.php";
session_start();
$player = $_SESSION['player'];
if (isset($_POST['move'])){
$move = $_POST['move'];
if ($move == 'down'){
mysql_query("Update movement set tile=tile+11 where name='$player'") or die (mysql_error());
$gettingtileinfo = mysql_fetch_array(mysql_query("Select * from movement where name='$player'"));
$tile = $gettingtileinfo['tile'];
echo '<div id="actor1_down"></div>';
}
}
?>
<script type="text/javascript">
var tile = tile_<? echo $tile; ?>;
</script>
btw I already changed this
Code: Select all
$("#"+tile).html(html);
Code: Select all
$("#tile_1").html(html);
any help would be appreciated thanks