Wednesday 18 June 2014

Dying to figure out what39s wrong with jquery code

Posted by Саша 03:40, under | No comments


Dying to figure out what's wrong with jquery code!? Dying to figure out what's wrong with jquery code!?

I have been banging my head against the wall trying to pass a game's name through to my php function as soon as a user clicks a button. The idea is the user clicks a button, which has a value of its videogame name, then the php script checks that game's ranking and returns that ranking to the html. I have made post requests work before, and even here when I manually set the variable name to one of the Games to test it, it works. Please help!
Here's the code:
<script>
$(document).ready(function(){
//global n variable
n = $();

$('#target').click(function(){
//set value of n to the game's name
n = $(this).val();

});

//then send the name as term to my php function to deal with it and return
//the ranking
$.post('getTotal.php', {term: n}, function(data){
//been trying to see if anything comes through for debugging purposes
alert(data);

//commented this out for now, just puts it in the div I left open
//$('#total').html(data);
});

});

</script>














0 коммент.:

Post a Comment