Return single value via AJAX Background

I have a Drupal 7 module that is making an AJAX call via jQuery.ajax() to a menu callback that I've defined in my module. The purpose isn't to return markup, but rather just a single string value.

This is all working as it should, but the method by which I'm passing the value back to jQuery seems messy to me.

I'm using:

// $condition is a simple string value.
print($condition);
drupal_exit();


My Question

Is there a cleaner, more standardized way of doing this? This just feels hackish and messy to me.

Thanks, Drupalers!
That will work, but here is how I would do it (in D7). You can set up the ajax callback server side like this:

$response = array('value' =&gt; $condition);
drupal_json_output($response);
drupal_exit();


Then your value will be available as data.value in your success callback:

$.ajax({
  url:example.com/some/path
  success:function(data) {
    alert(data.value);
  }
});