Note that there are some explanatory texts on larger screens.

plurals
  1. POHow To Get Variables Submitted by AJAX Using PHP Correctly?
    text
    copied!<p>I have this ajax/jquery code :</p> <pre><code>var headline = $("input#headline").val(); var subheadline = $("textarea#subheadline").val(); var pics = $("input#pics").val(); var dataString = 'headline='+ headline + '&amp;subheadline=' + subheadline + '&amp;pics=' + pics; $(".save-notice").hide(); $.ajax({ type: "POST", url: "web-block/forms/process-001.php", data: dataString, success: function() { $(".save-notice").show(); $(this).parents(".manage-content-wrap").next(".ribbon-content").fadeIn(); } }); </code></pre> <p>on the other side, I have this HTML form :</p> <pre><code>&lt;form action="" id="select-block" class="general-form"&gt; &lt;div class="input-wrap"&gt; &lt;input class="clearme" name="Headline" value="&lt;?php echo $Headline;?&gt;" id="headline"/&gt; &lt;/div&gt; &lt;div class="input-wrap"&gt; &lt;textarea class="clearme" name="Sub-Headline" id="subheadline"&gt;&lt;?php echo $SubHeadline;?&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;label&gt;Bottom Left Image&lt;/label&gt; &lt;div class="up-mask"&gt; &lt;span class="file-wrapper"&gt; &lt;input type="file" name="Pics" class="photo" id="pics" /&gt; &lt;span class="button"&gt; &lt;span class="default-txt"&gt;Upload Photo&lt;/span&gt; &lt;/span&gt; &lt;/span&gt; &lt;/div&gt;&lt;!-- .up-mask --&gt; &lt;input type="hidden" name="Key" value="&lt;?php echo $Key;?&gt;"/&gt; &lt;input type="submit" class="submit-btn" value="SAVE" /&gt; &lt;span class="save-notice"&gt;Your changed has been saved!&lt;/span&gt; &lt;/form&gt; </code></pre> <p>as you can see process-001.php is the file which process all variables from HTML form. but I have difficulties to 'catch' <code>$Headline</code> and <code>$SubHeadline</code> submitted by that form, which actually 'manipulates' by Ajax too...</p> <p>I tried using this code on process-001.php :</p> <pre><code>$Headline = $_POST['Headline']; $SubHeadline = $_POST['Sub-Headline']; </code></pre> <p>but seems that those variables are empty... how to get variables submitted by AJAX correctly?</p>
 

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