how to resolve ajax call once issue Drupal code

function form_example_form($form, &amp;$form_state)
{

    drupal_add_js(drupal_get_path('module', 'form_example') . '/js/test.js');

    $form['price_form'] = array(
        '#type' =&gt; 'fieldset',
        '#title' =&gt; t('Add Item'),
    );

    $form['price_form']['item'] = array(
        '#type' =&gt; 'textfield',
        '#title' =&gt; 'Item Name?',
        '#size' =&gt; 10,
        '#maxlength' =&gt; 25,
        '#required' =&gt; TRUE,
        '#ajax' =&gt; array(
            // #ajax has two required keys: callback and wrapper.
            // 'callback' is a function that will be called when this element changes.
            'callback' =&gt; 'form_example_simplest_callback',
            'wrapper' =&gt; 'listDiv',
            'effect' =&gt; 'fade',
        ),
    );

    $form['price_form']['textfields'] = array(
        '#prefix' =&gt; '&lt;div id="listDiv"&gt;',
        '#suffix' =&gt; '&lt;/div&gt;',
        '#markup' =&gt; '',
    );

    $form['price_form']['price'] = array(
        '#type' =&gt; 'textfield',
        '#title' =&gt; 'Item Price?',
        '#size' =&gt; 10,
        '#maxlength' =&gt; 10,
        '#required' =&gt; TRUE,
    );

    $form['price_form']['submit_button'] = array(
        '#type' =&gt; 'submit',
        '#value' =&gt; t('Click Here!'),
    );
    if (!empty($form_state['values']['item'])) {
        $result = db_query("SELECT * FROM {item} where item_name='" . $form_state['values']['item'] . "'");
        if ($result-&gt;rowCount() != 0) {
            $form['price_form']['textfields'] = array(
                '#markup' =&gt; 'Already exist',
            );
        } else {
            $form['price_form']['textfields'] = array(
                '#markup' =&gt; 'New Item',
            );
        }
    }

    return $form;
}

function form_example_simplest_callback($form, $form_state)
{
    return $form['price_form']['textfields'];
}


On blur of item textfield,I am showing status of item whether item_name exist in database or not.But It is showing perfectly for first time.

As it replaces a form name with 'form_name-2' after first ajax callback,it is not working afterwards.

How can I resolve this issue?

Thanks in advance
The problem is that you set your wrapper div in $form['price_form']['textfields'], but in the AJAX callback you are replacing it with the $form['textfields'] that does not have it defined. To be safe, keep these guidelines:


Never use the same identifier at 2 different depths of an form array, as it leads to mistakes. Be sure to set '#tree' =&gt; TRUE if you need to use identifier twice, to avoid conflicts.
In AJAX callback always return the same element you set '#prefix' =&gt; '&lt;div id="..."&gt; on.
Be sure to only define each element once. If you are using

$form['price_form']['textfields'] = array(
  '#prefix' =&gt; '&lt;div id="listDiv"&gt;',
  '#suffix' =&gt; '&lt;/div&gt;',
  '#markup' =&gt; '',
);


to define element, don't reset it with $form['price_form']['textfields'] = array( later in code. Using array() creates new empty array effectively deleting everything set earlier. Write directly to it's members like this: 

$form['price_form']['textfields']['#markup'] = t('Already exist');



Of course they are not set in stone, but don't break them unless you know why and what you're doing. In your case, you have 'textfields' twice, you are setting wrapper on one and returning another. That's why it only works once. Second time there is no element FAPI's AJAX is supposed to replace.