I’m trying to update the database using an ajax call from an accessory:
Every thing is working with the accessory, but I am making an Ajax call outside of EE framework to update the database. But I want to do this Ajax update withing the EE framework.
On this development page for EE: http://ellislab.com/expressionengine/user-guide/development/accessories.html
There is this bit: Processing Requests
Accessories have the ability to process requests for actions like AJAX calls. The following URL would be called C=addons_accessories&M=process_request&accessory=my_accessory&method=process_sample_process that requests the process_sample_process method in my_accessory
So I added the Ajax call:
$.ajax({
type : 'POST',
url : 'C=addons_accessories&M=process_request&accessory=hb_publish_help&method=update_help',
data : settings.data,
success : function(msg){
$(original_html).html(ckeip_html);
$('#ckeip_' + u_id + '').hide();
$(original_html).fadeIn();
console.log〈msg〉;
}
});Is there a setting I need to have that allows ajax calls to be made in the system?
And this function inside my acc. file
function update_help(){
if($this->EE->input->post('update_help') != ''){
$channel_id = "".$this->EE->input->get('channel_id');
// check if entry exists
$this->EE->db->select('file_id');
$this->EE->db->from('exp_hb_publish_help');
$this->EE->db->where('channel_id', $channel_id);
$check = $this->EE->db->get();
if($check->num_rows() > 0){
$data = array('help_text' => $text);
$this->db->where('channel_id', $channel_id);
$this->db->update('exp_hb_publish_help', $data);
}
else {
$data = array('help_text' => $text, 'channel_id' => $channel_id);
$this->db->insert('exp_hb_publish_help', $data);
}
// Kill EE Execution
exit();
}
}Moved to Development and Programming by Moderator
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.