Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The action of your form, since not specified, simply refreshes the page and submits <code>WallSubmit</code> and <code>Wall</code> to the main page, rather than to test.php. Instead, you could specify the action like so:</p> <pre><code>&lt;form action='test.php' id='wallForm' method='post'&gt; </code></pre> <p>However, this would simply take the user to a blank page with the contents of test.php. Instead, within the javascript, an ajax call must be made:</p> <pre> <code>$(document).ready(function() { ... $(document).on("submit","#wallForm",function(){ $.ajax({ type: "POST", url: $(this).attr('action'), cache: false, data: {Wall: $("#Wall").val(), wallSubmit: $("[name=WallSubmit]").val()}, success: function(html){ $("#content").html(html); } }); }); ... }); </code></pre> <p><code>on()</code> has to be called because the form was loaded after the DOM was. Javascript won't recognize it otherwise, as it only deals with content loaded into the DOM. For more information on this, <a href="http://www.quirksmode.org/js/events_order.html" rel="nofollow">this site</a> contains some useful information.</p> <p>If you want to have a generic form submission function, <code>serialize()</code> should probably do the trick. The <a href="http://api.jquery.com/serialize/" rel="nofollow">jQuery API page</a> should summarize this well. You would replace the <code>data: {Wall: ...}</code> with <code>data: $(this).serialize()</code>. This function takes the valid fields in a form and places it into a string that can be used to set data to a php file. However, I'm not quite sure what the effect the <code>WallSubmit</code> name has on the form. From what I can tell, you can eliminate that step altogether.</p>
    singulars
    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.
    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