How to get variable from javascript to php? -
i want variable code value:
/* link skor */ memory.prototype.cekskor = function(){ window.location = "./skor/index.php?value=" + this.nummoves; } memory.prototype._wingame = function() { var self = this; if (this.options.ongameend() === false) { this._cleargame(); this.gamemessages.innerhtml = '<h2 class="mg__onend--heading">keren!</h2>\ <p class="mg__onend--message">kamu memenangkan game ini dalam ' + this.nummoves + ' gerakan.</p>\ <button id="mg__onend--restart" class="mg__button">ingin bermain lagi?</button>\ <button id="mg__onend--skor" class="mg__button">cek skor?</button>'; this.game.appendchild(this.gamemessages); document.getelementbyid("mg__onend--restart").addeventlistener( "click", function(e) { self.resetgame(); }); document.getelementbyid("mg__onend--skor").addeventlistener( "click", function(e) { self.skor(); }); } else { // run callback this.options.ongameend(); } }
i want ( this.nummoves ) file index.php
<?php $skornya = $_get['value']; echo $skornya; ?>
when run web. error value= not read
what need solve problem ?
no way. =). in php can receive $_get, $_post, $_request, or $data = json_decode( file_get_contents('php://input') );
if want variable in javascript can use in php. must post server using xmlhttprequest in javascript, ajax in jquery. hope you
Comments
Post a Comment