Note that there are some explanatory texts on larger screens.

plurals
  1. POthe post method ajax
    primarykey
    data
    text
    <p>i did this code.there are two files( index.html and jeu.php) in the first , when i submit a form i will be redirect to the other page(jeu.php) so the problem is in the click event</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Jeu de dammes&lt;/title&gt; &lt;/head&gt; &lt;style&gt; form { margin-left:500px;margin-top:300px; width:300px } &lt;/style&gt; &lt;body&gt; &lt;form id="formulaire" style="margin-left:100px, padding: 15px" method="post" &gt; &lt;table&gt; &lt;tr&gt;&lt;td&gt;&lt;h4&gt; The first player&lt;/h4&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" id="premier" name="premier"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;h4&gt; The second player&lt;/h4&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" id="deuxieme" name="deuxieme"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt; &lt;button id="action"&gt;Play&lt;/button&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;script src="jquery-1.5.1.js"&gt;&lt;/script&gt; &lt;script&gt; $(function () { $('#formulaire').submit(function(e) { e.preventDefault(); var j1 = $('#premier').val(); var j2 = $('#deuxieme').val(); if (j1 == "") alert('saisir le nom du premier joueur'); if (j2 == "") alert('saisir le nom du deuxieme joueur'); if (j2 != "" &amp;&amp; j1 != "") { $.post('jeu.php', { premier: j1, deuxieme: j2}); window.location.href = "jeu.php"; } }); $('body').css('background-image', 'url(flower2.jpg)').css('background-size', '100%'); $("#formulaire").css('background-image', 'url(flower.jpg)'); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and in another file(jeu.php):</p> <pre><code>&lt;?php echo $_POST["premier"]."&lt;br/&gt;"; echo $_POST["deuxieme"]."&lt;br/&gt;"; ?&gt; </code></pre> <p>the problem :the page jeu.php is always empty </p> <ol> <li>why?</li> <li>how can i correct my code?</li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload