tags:

views:

33

answers:

1

I've always used ajax to load() the contents of a DOM element but now I'm trying set a form field value with the result of the following query:

$('#form_field').load(base_url+'ajax/get_yearly_fee', {
  'q_value': $(this).val(), 
  'client_id': $("#fee_client_add").val()
});

What's the best way to do this?

A: 

You can use jQuery.get() and add a callback to the end of this, see the .get documentation for a full description:

$.get(base_url+'ajax/get_yearly_fee', {
 'q_value': $(this).val(), 
 'client_id': $("#fee_client_add").val()
}, function(response) {
  $("#form_field").val(response);
});

Site note: Substitute .post for .get if you need to post the data instead.

Nick Craver
Works great, thanks!
stef