Problems using AJAX with single pages.
Permalink
Hello
Currently I'm trying to swap out content in a table with AJAX, depending on which "mode" the user selects(edit mode/delete mode). I don't have any previous experience using AJAX, so it's all new to me, which might also be the reason why I don't understand why it's not working. ^^
So far I've managed to use jQuery to make the request and pass data to the file targeted file.
The file which is supposed to be loaded, is placed within the "Tools" folder. My problem is I cannot use all the functionality within this file, as I could within the original view. First of all, I would like to use my jQuery functions, but I'm unable to do that within this file. I'm also unable to submit a form using $this->action('cat_change').
Here is the code of the targeted file:
I've tried loading the javascript functions again within the targeted file with
$this->addFooterItem($html->javascript('category_mode.js', 'ea_base')), but without any luck.
Currently I'm trying to swap out content in a table with AJAX, depending on which "mode" the user selects(edit mode/delete mode). I don't have any previous experience using AJAX, so it's all new to me, which might also be the reason why I don't understand why it's not working. ^^
So far I've managed to use jQuery to make the request and pass data to the file targeted file.
$( '#edit_mode' ).click(function(){ var edit_mode = $( '#edit_mode' ).val(); var categories_json = $( '#categories_json' ).html(); $.ajax({ type: 'POST', data: { categories_json: categories_json, mode: edit_mode }, url: edit_mode, success: function(response) { $('#category-table').html(response); } })
Viewing 15 lines of 16 lines. View entire code block.
The file which is supposed to be loaded, is placed within the "Tools" folder. My problem is I cannot use all the functionality within this file, as I could within the original view. First of all, I would like to use my jQuery functions, but I'm unable to do that within this file. I'm also unable to submit a form using $this->action('cat_change').
Here is the code of the targeted file:
<?php namespace Concrete\Package\EaBase\Tools; use Concrete\Core\Controller\Controller; use \Concrete\Core\Http\Request; use Core; use \Concrete\Package\EaBase\Models\CategorizerModel; use \Concrete\Package\EaBase\Libraries\BaseLibrary; class EditMode extends Controller { public function edit_table() { $categories = $this->post('categories_json'); $categories = json_decode($categories, true); $edit_mode_url = $this->post('mode'); ?> <div class="row">
Viewing 15 lines of 54 lines. View entire code block.
I've tried loading the javascript functions again within the targeted file with
$this->addFooterItem($html->javascript('category_mode.js', 'ea_base')), but without any luck.