Note that there are some explanatory texts on larger screens.

plurals
  1. POserializing and submitting a form with jQuery POST and php
    primarykey
    data
    text
    <p>i'm trying to send a form's data using jQuery. However, data does not reach the server. Can you please tell me what i'm doing wrong?</p> <pre><code> // FORM &lt;form id="contactForm" name="contactForm" method="post"&gt; &lt;input type="text" name="nume" size="40" placeholder="Nume"&gt; &lt;input type="text" name="telefon" size="40" placeholder="Telefon"&gt; &lt;input type="text" name="email" size="40" placeholder="Email"&gt; &lt;textarea name="comentarii" cols="36" rows="5" placeholder="Message"&gt; &lt;/textarea&gt; &lt;input id="submitBtn" type="submit" name="submit" value="Trimite"&gt; &lt;/form&gt; </code></pre> <p>Javascript: </p> <pre><code> Javascript Code in the same page as the form: &lt;script type="text/javascript"&gt; $(document).ready(function(e) { $("#contactForm").submit(function() { $.post("getcontact.php", $("#contactForm").serialize()) //Serialize looks good name=textInNameInput&amp;&amp;telefon=textInPhoneInput---etc .done(function(data) { if (data.trim().length &gt;0) { $("#sent").text("Error"); } else { $("#sent").text("Success"); } }); return false; }) }); &lt;/script&gt; </code></pre> <p>And server-side: </p> <pre><code> /getcontact.php $nume=$_REQUEST["nume"]; // $nume contains no data. Also tried $_POST $email=$_REQUEST["email"]; $telefon=$_REQUEST["telefon"]; $comentarii=$_REQUEST["comentarii"]; </code></pre> <p>Can you please tell me what am i doing wrong?</p> <p>EDIT: Checked <code>var_dump($_POST)</code> and it returned an empty array. </p> <p>The weird thing is that the same code tested on my local machine works fine. If i upload the files on my hosting space it stops working.<br> I tried doing an old-fashioned form without using jquery and all data is correct. </p> <p>I don't see how this would be a server configuration problem. Any ideas?</p> <p>thank you!</p>
    singulars
    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