Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Debbuging AJAX

Status
Not open for further replies.

youradds

Programmer
Jun 27, 2001
817
GB
Hi,

I'm trying to write a simple AJAX script, that will automatically change the "sub-category" dropdown, based on their State they selected.

Here is a trimmed down version of what I have:


Code:
<script type="text/javascript" src="/static/jquery.js"></script>

<script type="text/javascript" charset="utf-8">
 $(function(){
	 $("select#ctlJob").change(function(){
		 $.getJSON("/cgi-bin/ajax_cats.cgi",{id: $(this).val()}, function(j){
		
			 var options = '';
			 for (var i = 0; i <j.length; i++) {
				 options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
			 }
			 $("#catid").html(options);
			 $('#catid option:first').attr('selected', 'selected');
		 })
	 })
 })
</script>

I know ajax_cats.cgi is being run, as I'm outputting debugging stuff to STDERR (in Perl), so I can see whats outputted in the error_log.

Here is an example of what gets outputted when I call ajax_test.cgi?id=Alberta from a browser:

Code:
[ {optionValue: "Alberta", optionDisplay: '-- select category --'}, {optionValue: "25001", optionDisplay: 'Calgary > Airconditioning Heating Refridgeration'},{optionValue: "25007", optionDisplay: 'Calgary > Aluminum Metals Plastics Membranes Composite Materials'},{optionValue: "25017", optionDisplay: 'Calgary > Architechs Consultants Planning'}]

The form HTML I'm using is:


<form name="add_form_1" action="add1.cgi" method="POST">
<%include include_form_1.html%>
</form>

(the <%include thing is a template thing we have, which will include the form based on an included template file)

I don't see any error in FF's "Error Console", so I'm at a bit of a loss as to whats going on :/

Anyone got any suggestions?

TIA!

Andy
 
LOL, how typical! It was due to the > in the Full_Name stuff. Encoding that works - and its all good now :)

Cheers

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top