Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery not sending POST data
    primarykey
    data
    text
    <p>So I have a really simple form on a website that's entirely AJAX based for loading its pages. The only way for this form to work would be for it to do some AJAX magic as well, so I set about doing it. I had the form tested so I knew it all worked.</p> <p>Here's the javascript for my form. The variable "fullpath" just tells me what page is loaded at the moment, all of the pages are stored in the local "pages" directory. It serializes the form and sends it to the server, with some debugging alerts.</p> <pre><code>$(document).ready(function() { $("#regForm").submit(function(event) { alert($(this).serialize()); $.post("pages/" + fullpath, $(this).serialize(), function(data){ alert(data); }); return false; }); }); </code></pre> <p>Here's the form itself</p> <pre><code>&lt;form name="input" id="regForm"&gt; &lt;div class="form-field"&gt;&lt;label&gt;Username&lt;/label&gt; &lt;input type="text" name="username"/&gt;&lt;/div&gt; &lt;div class="form-field"&gt;&lt;label&gt;Password&lt;/label&gt; &lt;input type="password" name="password"/&gt;&lt;/div&gt; &lt;div class="form-field"&gt;&lt;label&gt;Confirm Password&lt;/label&gt; &lt;input type="password" name="password2"/&gt;&lt;/div&gt; &lt;div class="form-field"&gt;&lt;label&gt;Screen Name&lt;/label&gt; &lt;input type="text" name="screenname"/&gt;&lt;/div&gt; &lt;div class="form-field"&gt;&lt;label&gt;Email Address&lt;/label&gt; &lt;input type="text" name="address"/&gt;&lt;/div&gt; &lt;div class="form-field"&gt;&lt;label&gt;Group&lt;/label&gt; &lt;select name="usergroup"&gt; &lt;option value="0"&gt;Superuser&lt;/option&gt; &lt;option value="1"&gt;Admin&lt;/option&gt; &lt;option value="2"&gt;Moderator&lt;/option&gt; &lt;option value="3"&gt;Advmember&lt;/option&gt; &lt;option value="4"&gt;Member&lt;/option&gt; &lt;option value="5"&gt;Guest&lt;/option&gt; &lt;/select&gt; &lt;br /&gt; &lt;label&gt;Submit: &lt;/label&gt;&lt;input type="submit" value="Submit" /&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>And here's some PHP I put at the beginning of the page</p> <pre><code>print_r($_POST); </code></pre> <p>So I fill the form with some bogus info, and I press submit. All of the data is displayed with the</p> <pre><code>alert($(this).serialize()); </code></pre> <p>And then the call is successful and I see the loaded form with my</p> <pre><code>alert(data); </code></pre> <p>But, where I ask to print the $_POST array in PHP, this is all I get</p> <pre><code>Array () </code></pre> <p>So jQuery is sending the data, it's getting the page back, but for some reason the POST variables aren't going through. Anyone care to lend a hand?</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.
 

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