I am trying to make a simple game and I'm not very good with jQuery. The code I have is:
<script type="text/javascript">
$(document).ready(function(){
$('#deposit').click(function(){
$.ajax({
type: 'POST',
url: 'update.php',
dataType: 'json',
data: {
Money : $('#input_money').val()
},
success: function(data){
$('#display').html(data.value);
}
});
});
});
</script>
And the display is this:
<input id="input_money" name="input_money" type="text" size="40"><br><br>
<button id="deposit">Deposit Money</button>
<div id="display"></div>
For the back end, I am using this:
if(isset($_POST['Money'])){
$value = $_POST['Money'];
} else {
$value = "";
}
echo json_encode(array("value"=>$value));
Can anyone help me out? I plan to add the $value
into a database after it shows up on the main page.
Thanks
I fired this on my serv, find it at: this link
It works just fine. Heres the source, just like yours.
Hope youll get it to work. Best regards Jonas