We help IT Professionals succeed at work.

Can't Get Values to POST to a script via jQuery

Elxn
Elxn asked
on
I've got a page, you can check out all the code by going here.  
Next click on the "criteria" tab and you'll see the form.

The form HTML is like:  <form id="basic_search_form">

The function called on click is as follows:
 function basic_search(){ 
      $("#ajax-block-2").empty();
	  $("#criteria_tab").removeClass("selected");
	  $.when(show_loader()).done(function(a1){
		  $.ajax({
			url: 'php/pic-search.php?use=rating',
			type: 'POST',
			data: $('form#basic_search_form').serialize(),
			success: function(data) {
				$("#big-loader").remove(); 
				$("#ajax-block-2").html(data);
			},
			error: function(xhr, textStatus, errorThrown){
				alert("There was an error: "+textStatus);
				$("#big-loader").remove();
			}
		});
	});		
 }

Open in new window


The page produces data and this gets appended to the page, so I know its working kind of.  But for some reason there is no POST data being sent.  The post data keeps being empty for some reason.

Thanks for any help!
Comment
Watch Question

Commented:
I don't see a form with that ID in your source.

Commented:
Ah, okay, so it's loading up on AJAX or something. I would suggest just using Firebug to add breakpoints to your $.ajax line and run the search. Then when it hits the breakpoint, run the serialize manually:

$('form#basic_search_form').serialize();

...and see what the output is. Inspect all of the values in your AJAX request.
Elxnboss

Author

Commented:
yeah its ajaxed in... you can check it out in chrome with "inspect element" it shows all the code that is there including ajaxed stuff.
boss
Commented:
OKay, I was a bit of a fool here.  The reason it wouldn't work was cause I emptied the form from the page before I tried to serialize the data, so there was no form to get data from.

Thanks for the help.
Elxnboss

Author

Commented:
solved myself.  Close it up.