Welcome Guest, Not a member yet? Register   Sign In
Opening a new page w/ dynamic data
#1

(This post was last modified: 03-03-2017, 11:34 AM by codeguy.)

I'm trying to learn CI by converting an existing php app. In response to a click event I need to open a new page and pass an id to the controller. This allows the controller to populate the page with data, appropriate to the particular element of that class that was clicked. In the original version I just passed the ID to the controller along with the url (in the 'get' array)  Here's the js/jq code in my new CI code version that registers the event and provides the initial response:

    $('.tsEditButt').click(function() {
        var tuneID=$(this).closest('.tune').attr('id');
        window.open('c_tunesheet','_blank');
        $.post('c_tunesheet',{tuneID:tuneID},function(response) {
            alert('Response: '+response);  // For testing the strategy
        });
    });

The c_tunesheet controller to test this strategy:

    class C_tunesheet extends CI_Controller {
        function  __construct()   {
            parent::__construct();
            $this->load->helper('url');
        }
    public function index() {  // index function loads new tunesheet editor page / with this tune's data
        $pageTitle='MZ TS Editor';
        $tuneID=$this->input->post('tuneID');

        echo('<div>C_tunesheet, tuneID:'.$tuneID.' PageTitle:'.$pageTitle.'</div>');
    }
}

The problem:

Firebug (and the alert message correctly appearing in the first page) shows the expected string returned to the js/jq calling function as:


Code:
<div>C_tunesheet, tuneID:1632 PageTitle:MZ TS Editor</div>

But, the html that appears on the new page is:

    C_tunesheet, tuneID: PageTitle:MZ TS Editor

i.e. the $tuneID value is not getting passed to the controller. I suspect I'm missing something very fundamental here re: what happens within the CI app when a new page is opened. Hopefully someone can point me in the right direction. Thanks in advance.
Reply


Messages In This Thread
Opening a new page w/ dynamic data - by codeguy - 03-03-2017, 10:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB