I have a drop down menu with a change event that makes a JQuery JSON AJAX request, which I’ve simplified for this post:
$('#id_template').change( function() {
var data = {
action: 'change_template'
};
$.getJSON( '/ajax/index.php/section/', data, function( response, status ) {
if( status == 'success' ) {
$('#id_parent_section').html( response.id_parent_section );
}
});
return false;
});
This AJAX request calls the following PHP function (simplified too):
protected function change_template() {
$this->response['id_parent_section'] = 'yes';
echo json_encode( $this->response );
}
When I do change the drop menu’s value, the request seems to be successfully sent with a successful reply received (inspected it in Firebug), as the content in the “status == success” is accessed. However, the problem is the response is null.
I don’t have this problem when I’m testing on my local WAMP setup, and so have no idea why everything appears to be working fine here except the retrieval of the response array.
Any help is much appreciated.