views:

18

answers:

2

I have a load action tied to the submit button of a form.

jQuery('#content').load("/control/ajxdata/installs.php?country=" + country);

jQuery('#content').load("/control/ajxdata/installs.php",{ 'country': country });

The name, and the id of the form element I am trying to utilize is "country"

In the error console, I am getting "Error: country is not defined"

+3  A: 

Try

jQuery('#content').load(
    "/control/ajxdata/installs.php",
    {'country': $("#country").val()}
);

$("#country").val() is the jQuery way to select the element which has the input with id country and get it's value.

jitter
+1  A: 

Assuming country is an input field, you would do this to get its value...

<input type="text" id="country">

jQuery('#content').load("/control/ajxdata/installs.php?country=" + $('#country').val());

But, it might be better to set the 'name' attribute, instead of the id. It makes your code easier to maintain (in 6 months when you forget what, or where, #country is). It also makes it easier to use form handling plugins (there are hundreds of form related jquery plugins), as most of them use the 'name' attribute to serialize data.

<input type="text" name="country">

jQuery('#content').load("/control/ajxdata/installs.php?country=" + $('input[name=country]').val());
John Himmelman