-6

I want to grab the return Gameresult value in php which came with the Jquery id call

The html tag

<p id="gameresult">

</p>

i want to grab the value into php which will be appended here

the Jquerypart :

this.enter = function() {
        var obj = g;
        g.platform.soundManager.gameover.play();
        var result = $('<ul><li>You type '+g.score.score+' characters in '+g.time.time+' seconds.</li><li><u>Your speed</u> : about ' + Math.floor( (Math.ceil(g.score.score / 5) / g.time.time) * 60) +' words per minutes!</li></ul>');
        g.platform.stopAnim();
        this.hideMenu();
        $('#gameresult').append(result);
        this.showState(this.screen);

below is the link:

bubbletyping.base.pk

just play the game at the top left corner for demo..

NASIR KHAN
  • 13
  • 2
  • 9

1 Answers1

0

Remove the $() stuff around your result string. Also, you should check to make sure g.time.time isn't zero before division.

var speed = (g.time.time === 0 ? 0 : Math.floor( (Math.ceil(g.score.score / 5) / g.time.time) * 60))
var result = '<ul><li>You type '+g.score.score+' characters in '+g.time.time+' seconds.</li><li><u>Your speed</u> : about ' + speed +' words per minutes!</li></ul>;

Here is a JS Fiddle demo

devlin carnate
  • 8,309
  • 7
  • 48
  • 82
  • Thanks devlin carnate but what i am trying to get the result from the Jquery part or html part and assign it to a php variable..how can i do that..Thanks For the help – NASIR KHAN Nov 11 '15 at 18:47
  • You would do that using AJAX. http://stackoverflow.com/questions/24586471/how-to-send-or-assign-jquery-variable-value-to-php-variable – devlin carnate Nov 11 '15 at 19:23