Updating fields on a form with Ajax and Json

Comparing #2 with #3

Content

[...]
Yii::app()->end();
}
catch (SoapFault $soapFault)
{
// Theres a problem with SOAP
// or the enquire() function threw an error, an invalid registr
istration number for example
$status = 'HPI Error : ' . substr($soapFault->faultcode, strlen('soapenv:'));
$status .= ' (' . $soapFault->detail->HpiSoapFault->Error->Code . ') ';
[...]
// Data to be passed to the ajax function
// Not
e that the ' should be escaped with \
// The field id should be prefixed with the model name eg Vehicle_field_name
'data'=>array('registration_number'=>'js:$(\'#Vehicle_registration_number\').val()',
[...]
// Then change the selected option
$('#Vehicle_vehicle_colour_id').val(data.colour_id);
if (data.makeOption
!='') $('#Vehicle_vehicle_make_id').append(data.makeOption); $('#Vehicle_vehicle_make_id').val(data.make_id); if (data.modelOption!='') $('#Vehicle_vehicle_model_id').append(data.modelOption);
$('#Vehicle_vehicle_model_id').val(data.model_id);
}

} ",
))?>;
[...]