In this form, users can add information for authors (music, lyrics authors)
Users can add 1 or more authors.
The problem is that when the user enters only one author, all other inputs remain empty, but the jQuery serialization function will still put them in the url and the server gives me this error:
Request-URI Too Large
See an example below:
echo "<form action=\"\" id=\"submForm\" name=\"submForm\" method=\"get\">"; // AUTHOR NUMBER 1 echo "<p><span class=\"labelInput\">".(_t('_cR_name'))." </span><input id=\"nameAuthor\" name=\"author[0][name]\" value=\"\" type=\"text\" class=\"commonInput\"></p>"; echo "<p><span class=\"labelInput\">".(_t('_cR_DOB'))." </span><input id=\"DOBAuthor\" name=\"author[0][DOB]\" value=\"\" type=\"text\" class=\"littleInput\"></p>"; echo "<p><span class=\"labelInput\">".(_t('_cR_DOD'))." </span><input id=\"DODAuthor\" name=\"author[0][DOD]\" value=\"\" type=\"text\" class=\"littleInput\"></p>"; // AUTHOR NUMBER 2 echo "<p><span class=\"labelInput\">".(_t('_cR_name'))." </span><input id=\"nameAuthor\" name=\"author[1][name]\" value=\"\" type=\"text\" class=\"commonInput\"></p>"; echo "<p><span class=\"labelInput\">".(_t('_cR_DOB'))." </span><input id=\"DOBAuthor\" name=\"author[1][DOB]\" value=\"\" type=\"text\" class=\"littleInput\"></p>"; echo "<p><span class=\"labelInput\">".(_t('_cR_DOD'))." </span><input id=\"DODAuthor\" name=\"author[1][DOD]\" value=\"\" type=\"text\" class=\"littleInput\"></p>"; Death: // AUTHOR NUMBER 3 echo "<p><span class=\"labelInput\">".(_t('_cR_name'))." </span><input id=\"nameAuthor\" name=\"author[2][name]\" value=\"\" type=\"text\" class=\"commonInput\"></p>"; echo "<p><span class=\"labelInput\">".(_t('_cR_DOB'))." </span><input id=\"DOBAuthor\" name=\"author[2][DOB]\" value=\"\" type=\"text\" class=\"littleInput\"></p>"; echo "<p><span class=\"labelInput\">".(_t('_cR_DOD'))." </span><input id=\"DODAuthor\" name=\"author[2][DOD]\" value=\"\" type=\"text\" class=\"littleInput\"></p>"; echo "</form>";
And this is jQuery code (it also includes a validation function, I'm on jQuery 1.3.2)
echo "<script type=\"text/javascript\"> $(document).ready(function() { $('#submForm').validate({ submitHandler: function(form) { var serialized = $('#submForm').serialize() $.get('".$site['url']."modules/yobilab/copyright/classes/DO_submission.php', serialized); window.setTimeout('location.reload()', 8000); return false; form.submit(); } }) });
Now let's say that the user will enter the fields ONLY for AUTHOR 1 and leave AUTHOR 2 and AUTHOR 3 empty. How can I say that the jQuery serialization function should include ONLY entered fields in the URL and DO NOT include empty fields?
source share