Using:
CakePHP 1.1.19.6305
jquery-1.2.6.min.js

In the view:

<tr><td align="right" class="label_14" width="200px">select a
campaign:&nbsp;</td><td align="left"><?php echo $html-
>selectTag( 'Campaign/CampaignID', $options_C, null, array( 'onchange'
=> 'display_select_event()','id' => 'select_campaign' ), null, true,
false ); ?></td></tr>

In the JavaScript:

function display_select_event()
{
  .
  .
  .
  // get the events for this campaign.
  $.get( 'Attendance/get_events', { campaign_id: selected_index },
function( xml ) { alert( xml  ); }, 'XML' );
  .
  .
  .
}

In the controller:

  function get_events( $campaign_id )
  {
    $conditions = array( 'CampaignID' => $campaign_id );
    $fields = array( 'CEventID', 'Name' );
    $result = $this->Event->findAll( $conditions, $fields, null, null,
1, null );

    if( count( $result ) )
    {
      $xml = '<?xml version=\"1.0\" standalone=\"yes\"?>';

      foreach( $result as $key => $value )
      {
        foreach( $value as $id => $name )
        $xml .= '<event>';
        $xml .= '<id>' . $value['Event']['CEventID'] . '</id>';
        $xml .= '<name>' . $value['Event']['Name'] . '</name>';
        $xml .= '</event>';
      }
    }
    else
    {
      // What if there are no events for this campaign.
    }
  }

The function, get_events(), produces the correct, well-formed XML
document. But Cake is complaining about the missing view for
"get_event" and the jQuery is not returning the XML document produced
by get_events().

A link to an example of what I am trying to do would be sufficient and
greatly appreciated but if you spot the errors in my code that would
be appreciated also.

Peter -


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to