I am getting may well trouble with my script. The purpose is always to obtain a some rows formatted inside a table however the header shouldn't be repeated and under all of the products ought to be outputted and than as variable passed to ajax . However I aren't seeing how you can solve this.

 function abc()
   {
      global $mainframe;

      $db      =& JFactory::getDBO();

      // Check for request forgeries
        if(isset($this->message)){
                $this->display('message');
   }
                // custom: generate token for ajax request
                        $ajax_token = JHTML::_( 'ajax.token' );
                            // custom end

//        JRequest::checkToken( 'get' ) or jexit( 'Invalid Token' );



        $letter_raw = JRequest::getVar('val');
        $letter = substr($letter_raw, -1);
        $response = '<div class="no-rec">not found</div>';
        $html = '';
        if (!empty($letter)) {
        $query = " SELECT * FROM #__glossary WHERE substr(tterm,1,1) LIKE '$letter%'";

        $db->setQuery( $query );

        $rows = $db->loadObjectList();


        if (count($rows)) {

        $header='<table class="stripeMe"><tbody><thead><tr><th>Begriff</th><th>Definition</th></tr></thead><tr>';

        foreach($rows as $key => $row) {

        $body='<td><span class="title">'.$rows[$key]->tterm.'</span></td><td>'.$rows[$key]->tdefinition.'</td></tr></tbody></table>';

        }

        $response = $header.$body;


        }

        $html = $response;

        echo $html;




        }



   }

What is the issue? :)

You need to proberbly not allow it to be an function, since i have guess you simply likely to load this content along with AJAX?

And you ought to Increase string not override in every row.

Up-to-date, FIXED HTML ERRORS

    if (count($rows)) {
    // CREATE TABLE AND HEAD
    $body = '<table class="stripeMe"><thead><tr><th>Begriff</th><th>Definition</th></tr></thead>';

    // TBODY FOR REPEAT INSIDE
    $body .= '<tbody>'
    foreach($rows as $key => $row) {
    $body .= '<tr><td><span class="title">'.$rows[$key]->tterm.'</span></td><td>'.$rows[$key]->tdefinition.'</td></tr>';
    }
    $body .= '</tbody></table>';

    $response = $body;
    }

    $html = $response;

    echo $html;

Well if you're passing the information back as HTML than this works so that your jquery could be:

$('#holderdiv').load('abc.php');

If you work with Something similar to .publish .ajax .get, then you will have to decide what format to pass through the information back with the whether it's JSON then you will have to format it as being such and make certain that the jQuery is told to anticipate this type of response. I'm able to give more help if you're able to be specific regarding your situation and what problems you're getting.