Jump to content

[SOLVED] Serializing my form using jquery only returns a single result


lonewolf217

Recommended Posts

This is what I am working with right now.  I have a large form with multiple text, select and select multiple elements

 

	<script type="text/javascript">
		$(document).ready(function() {
			var jInput = $(":input");
			$("#submit").click(function() {
				var str = $("#resFilters").serialize();
				alert(str);
				$.post("test.php",$("#resFilters").serialize(),function(data) {
					if(data.length > 0) {
						$('#resources').fadeIn('slow');
						$('#resources').html(data);
					}
				});
				return false;	
			});
		});	

	</script>

 

on my backend page, i do

<?php
echo "<pre>";
print_r($_POST);
echo "</pre>";

 

and for one of my select multiple fields on which I had selected multiple elements, it is only displaying one result, the last result

 

I have tried doing some research on how serialize works, but all I can find is that it is supposed to handle multiple selects without a problem, but I do not know how much simpler I can make it.  if I output an alert from my main page with the contents of the serialized form, I can see that it is formatted like "OS=windows&OS=unix", but how do I retrieve it?

I tried

<?php
foreach($_POST['OS'] as $os) {
	echo "OS=".$os."<br>";
}

but it outputs nothing, so now I am a little more confused why print_r($_POST) returns something, but not this

 

any help, or shove in the right direction is appreciated

  • 2 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.